JSP taglib 指令错误
我在 weblogic 中部署时收到以下错误:
解析JSP文件'/pages/RegisteredEmployee.jsp'失败:/pages/RegisteredEmployee.jsp(5):使用标签库uri='/WEB-INF/struts-html.tld' prefix='html时出错': Tag 类 'org.apache.struts.taglib.html.FormTag' 没有与 TLD 声明的属性 'name' 对应的 setter 方法,(JSP 1.1 规范,5.4.1)可能由于 /pages/ 中的错误而发生RegisteredEmployee.jsp 第 5 行:
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
我的 struts-html.tld
位于 /WEB-INF
文件夹内。我还尝试将标签库指令路径更改为http://jakarta.apache.org/struts/tags-html,它显示了相同的错误。我还将 struts-html.tld
复制到 /WEB-INF/lib
中,它显示了相同的错误。
我该如何解决这个问题?
RegisteredEmployee.jsp
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<html:html>
<html:form action="reg employee">
<body>
<center>
<table>
<tr>
<td>Employee Id:</td>
<td><html:text property="id"/></td>
<td><html:submit value="Login to see your details"></html:submit></td>
</tr>
</table>
</center>
</body>
</html:form>
</html:html>
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/pages/RegisteredEmployee.jsp</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
</web-app>
I receive the following error while deploying in weblogic:
Parsing of JSP File '/pages/RegisteredEmployee.jsp' failed: /pages/RegisteredEmployee.jsp(5): Error in using tag library uri='/WEB-INF/struts-html.tld' prefix='html': The Tag class 'org.apache.struts.taglib.html.FormTag' has no setter method corresponding to TLD declared attribute 'name', (JSP 1.1 spec, 5.4.1) probably occurred due to an error in /pages/RegisteredEmployee.jsp line 5:
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
My struts-html.tld
is inside /WEB-INF
folder. I also tried to change the tag lib directive path to http://jakarta.apache.org/struts/tags-html
, it displayed same error. I also copied struts-html.tld
into /WEB-INF/lib
, it displayed same error.
How can I solve this problem?
RegisteredEmployee.jsp
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<html:html>
<html:form action="reg employee">
<body>
<center>
<table>
<tr>
<td>Employee Id:</td>
<td><html:text property="id"/></td>
<td><html:submit value="Login to see your details"></html:submit></td>
</tr>
</table>
</center>
</body>
</html:form>
</html:html>
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/pages/RegisteredEmployee.jsp</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
</web-app>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题可以在这里找到:
我已经好几个月没有使用 Struts 了,但它在
value="..."
上抱怨。相反,
上(可能)没有属性value
。The problem can be found here:
I haven't done Struts in months, but it's complaining on
value="..."
. Rather do this,There's (probably) no attribute
value
on<html:submit>
.