JSTL:JSP 标准标签库,可以编写没有java代码的jsp页面,有了它,基本上Java的代码就会变少,甚至没有,所以想用一些
一、下载jar包
因为这个东西不是原有的,所以一定要下载jar包才可以,
下载地址是:http://archive.apache.org/dist/jakarta/taglibs/standard/binaries/
下载jakarta-taglibs-standard-1.1.1.zip这种.zip的文件,至于版本应该是都可以吧
二、jar包放到项目下
1、在jakarta-taglibs-standard-1.1.1\lib下找到jar包
2、把jar包放到项目的WebContent\WEB-INF\lib下
三、在web.xml里写配置信息
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID"
version="3.1"
metadata-complete="true">
<display-name>RDWork</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/fmt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/fn</taglib-uri>
<taglib-location>/WEB-INF/fn.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/perTag</taglib-uri>
<taglib-location>/WEB-INF/permittedTaglibs.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
<taglib-location>/WEB-INF/sql.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/script</taglib-uri>
<taglib-location>/WEB-INF/scriptfree.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/x</taglib-uri>
<taglib-location>/WEB-INF/x.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>
<jsp-config>...</jsp-config>一定要加并写对位置,否则会出现cvc-complex-type.2.4.a: Invalid content was found starting with element 'taglib'.的问题,此处参考http://blog.csdn.net/lopper/article/details/4836252
四、把tld放到项目里
其查资料的时候这一步有人不需要,但是我的还是没有办法使用JSTL,但是要加进去就好了。
jakarta-taglibs-standard-1.1.1中文件夹下的tlb
放到WebContent\WEB-INF下
这样应该就不会有问题了