How to check whether the JSTL installation is successful?

After the JSTL installation is complete, you need to test whether the JSTL installation is successful. Since we use the <c:out> tag when testing, we need to use the taglib instruction to import the Core tag library. The specific code is as follows:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

In the above code, the uri attribute of the taglib instruction is used to specify the URI of the tag library descriptor file, and the prefix attribute is used to specify the prefix of the tag library descriptor file. When a tag in this tag library is used in the JSP file , All need to use this prefix.

Next, write a simple JSP file test.jsp, use the taglib instruction to import the Core tag library, and use the <c:out> tag in the file, as shown in Example 1.

Example 1 test.jsp

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
   <head></head>
   <body>
     <c:out value="Hello World!"></c:out>
   </body>
</html>

Open the IE browser and enter http://localhost:8080/chapter08/test.jsp in the address bar to access the test.jsp page. At this time, the result displayed in the browser window is shown in Figure 1.

1608023499844_JSTL install.png

Figure 1 test.jsp

It can be seen from Figure 1 that when using a browser to access the test.jsp page, "Hello World!" is output, which shows that the JSTL tag is successfully installed.

Guess you like

Origin blog.csdn.net/cz_00001/article/details/111636423