在老版本的Struts中,需要如下配置:
1. 添加tld标签库文件
一共有五大标签库文件,他们是:
struts-html.tld |
struts-bean.tld |
struts-logic.tld |
struts-tiles.tld |
struts-nested.tld |
将上面这些文件拷贝到你的项目WEB-INF目录
--> %WebApp%/WebRoot/WEB-INF
2. 在web,xml中:
- <jsp-config>
- <taglib>
- <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
- <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
- </taglib>
- <taglib>
- <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
- <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
- </taglib>
- <taglib>
- <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
- <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
- </taglib>
- <taglib>
- <taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
- <taglib-location>
- /WEB-INF/struts-nested.tld
- </taglib-location>
- </taglib>
- <taglib>
- <taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
- <taglib-location>
- /WEB-INF/struts-template.tld
- </taglib-location>
- </taglib>
- <taglib>
- <taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
- <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
- </taglib>
- </jsp-config>
3. 在jsp页面中:
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
在1.3.8之后的版本中,新的struts将tld文件放在struts-taglib.jar文件中了,tomcat等容器启动的时候会自动加载jar文件中的META-INF中的tld文件。所以不需要拷贝tld文件到WEB-INF 中,也不需要在web.xml中声明,只需要在页面中这样引用即可:
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>