文件“/struts-tags” Struts 1.3 中未找到

发布于 2024-11-15 16:14:06 字数 3775 浏览 1 评论 0原文

我在jsp中的logic:iterate内编写了一个条件if else标签,如下所示:-

<s:if test="%{#status=='Scheduling'}">
<td><input type="button" name="Save" enabled="enabled" value="View Log" class="Button" onclick="javascript:update('<bean:write  name="test" property="listName" />','<bean:write name="test" property="testType" />',<bean:write  name="test" property="status" />,this.value)"></td>
</s:if>

<s:elseif test="%{#status=='Running'}">
<td><input type="button" name="Save" enabled="enabled" value="View Log" class="Button" onclick="javascript:update('<bean:write  name="test" property="listName" />','<bean:write name="test" property="testType" />',<bean:write  name="test" property="status" />,this.value)"></td>                
</s:elseif>

<s:else>
<td><input type="button" name="Save" disabled="disabled" value="View Log" class="Button" onclick="javascript:update('<bean:write  name="test" property="listName" />','<bean:write name="test" property="testType" />',<bean:write  name="test" property="status" />,this.value)"></td>                   
</s:else> 

我定义了一个<%@taglib prefix="s" uri= "/struts-tags" %> 在 jsp 文件的开头,如下所示:-

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@taglib prefix="s" uri="/struts-tags" %> 

当我打开 jsp 文件时,出现以下错误。你能帮我解决这个问题吗?

org.apache.jasper.JasperException: File "/struts-tags" not found
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)
    org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:160)
    org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:429)
    org.apache.jasper.compiler.Parser.parseDirective(Parser.java:492)
    org.apache.jasper.compiler.Parser.parseElements(Parser.java:1439)
    org.apache.jasper.compiler.Parser.parse(Parser.java:137)
    org.apache.jasper.compiler.ParserController.doParse(ParserController.java:255)
    org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:170)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
    org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

I wrote a conditional if else tag inside a logic:iterate in jsp as below:-

<s:if test="%{#status=='Scheduling'}">
<td><input type="button" name="Save" enabled="enabled" value="View Log" class="Button" onclick="javascript:update('<bean:write  name="test" property="listName" />','<bean:write name="test" property="testType" />',<bean:write  name="test" property="status" />,this.value)"></td>
</s:if>

<s:elseif test="%{#status=='Running'}">
<td><input type="button" name="Save" enabled="enabled" value="View Log" class="Button" onclick="javascript:update('<bean:write  name="test" property="listName" />','<bean:write name="test" property="testType" />',<bean:write  name="test" property="status" />,this.value)"></td>                
</s:elseif>

<s:else>
<td><input type="button" name="Save" disabled="disabled" value="View Log" class="Button" onclick="javascript:update('<bean:write  name="test" property="listName" />','<bean:write name="test" property="testType" />',<bean:write  name="test" property="status" />,this.value)"></td>                   
</s:else> 

I defined a <%@taglib prefix="s" uri="/struts-tags" %> in the beginning of the jsp file as shown below:-

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@taglib prefix="s" uri="/struts-tags" %> 

When I am opening the jsp file i am getting the following errors. Could you help me in resolving this?

org.apache.jasper.JasperException: File "/struts-tags" not found
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)
    org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:160)
    org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:429)
    org.apache.jasper.compiler.Parser.parseDirective(Parser.java:492)
    org.apache.jasper.compiler.Parser.parseElements(Parser.java:1439)
    org.apache.jasper.compiler.Parser.parse(Parser.java:137)
    org.apache.jasper.compiler.ParserController.doParse(ParserController.java:255)
    org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:170)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
    org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

长安忆 2024-11-22 16:14:06

您正在将 Struts 1.3 标签与 Struts 2 标签混合在一起。为了使 taglib 声明 <%@ taglib prefix="s" uri="/struts-tags" %> 能够编译,您必须包含 struts2-core-2.1。 6.jar(撰写本文时的最新 jar)在您的 WEB-INF\lib 文件夹中,Struts 2 struts-tags.tld 位于(struts2-core-2.1.6.jar\META-INF\struts-tags.tld)。

请记住,Struts 2永远向后兼容 Struts 1,因为它是一个全新的架构,Apache 已从 Struts 1 中采取了新的方向。

我建议使用 JSTL,而不是使用 Struts 2 taglib 定义,因为 Struts 1.3 可以工作与 JSTL 合作良好。

You are mixing the Struts 1.3 tags with the Struts 2 tags. In order for your taglib declaration <%@ taglib prefix="s" uri="/struts-tags" %> to compile, you must include the struts2-core-2.1.6.jar (latest jar at the time of writing) in your WEB-INF\lib folder, Struts 2 struts-tags.tld is found under (struts2-core-2.1.6.jar\META-INF\struts-tags.tld).

Bear in mind that Struts 2 is never backward compatible with Struts 1 as it's a completely new architecture Apache has taken new direction from Struts 1.

I suggest using JSTL instead of using Struts 2 taglib definitions as Struts 1.3 works well with JSTL.

往事风中埋 2024-11-22 16:14:06

在您的部署描述符(即 web.xml)中,您应该声明类似以下内容。 (请记住将 tld 文件放在您的 taglib 位置中)

   <jsp-config>
     <taglib>
       <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
       <taglib-location>/WEB-INF/tlds/struts-html.tld</taglib-location>
     </taglib>
   </jsp-config>

in your deployment descriptor, that is web.xml, you should have something like the following declared. (remember to have the tld files in your that taglib-location)

   <jsp-config>
     <taglib>
       <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
       <taglib-location>/WEB-INF/tlds/struts-html.tld</taglib-location>
     </taglib>
   </jsp-config>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文