JSP taglib 指令错误

发布于 2024-09-15 04:55:47 字数 2674 浏览 3 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゞ花落谁相伴 2024-09-22 04:55:51

问题可以在这里找到:

<html:submit value="Login to see your details"></html:submit>

我已经好几个月没有使用 Struts 了,但它在 value="..." 上抱怨。相反,

<html:submit>Login to see your details</html:submit>

上(可能)没有属性 value

The problem can be found here:

<html:submit value="Login to see your details"></html:submit>

I haven't done Struts in months, but it's complaining on value="...". Rather do this,

<html:submit>Login to see your details</html:submit>

There's (probably) no attribute value on <html:submit>.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文