问题
访问Struts标记库JSP文件时,Struts会出现常见错误消息。
org.apache.jasper.JasperException: The absolute uri:
http://struts.apache.org/tags-bean
org.apache.jasper.JasperException: The absolute uri:
http://struts.apache.org/tags-html
org.apache.jasper.JasperException: The absolute uri:
http://struts.apache.org/tags-logic
org.apache.jasper.JasperException: The absolute uri:
http://struts.apache.org/tags-tiles
cannot be resolved in either web.xml or
the jar files deployed with this application
解
这是因为您没有配置Struts标记库属性,所以在项目依赖项中找不到tld文件。
1. Strut标签库手动配置
如果您是手动配置Struts标记库,则在Struts版本<= 1.1和Servlet <2.3容器中使用 。 请确保将以下“ tld ”文件复制到WEB-INF文件夹,您可以在Struts库文件夹中找到这些文件。
- struts-bean.tld
- struts-html.tld
- struts-logic.tld
- struts-tiles.tld
并在web.xml中正确定义
web.xml
...
<taglib>
<taglib-uri>
http://struts.apache.org/tags-bean
</taglib-uri>
<taglib-location>
/WEB-INF/struts-bean.tld
</taglib-location>
</taglib>
...
2. Strut标签库自动配置
如果要自动配置Struts标记库,则在Servlet 2.3 / 2.4版和Struts 1.2或1.3框架中使用。 确保struts-taglib.jar位于/ WEB-INF / lib目录中。
您可以在此处检查Struts标记库的配置详细信息 。
3. Eclipse IDE调试会话
如果这是在Eclipse IDE调试会话期间发生的,只需确保将项目依赖项部署到正确的文件夹即可。 请查看本文以获取解决方案 。
结论
问题的原因可能因项目而异,但解决方案始终相同
- 检查tld文件是否在WEB-INF(旧的Struts样式)中可用。
- 检查taglib uri是否有拼写错误。
- 检查struts-taglib.jar是否在/ WEB-INF / lib或项目依赖项中可用(新的Struts样式)。
标签: Struts