java 在 Struts 1.3 中找不到文件“/struts-tags”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6339323/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
File "/struts-tags" not found in Struts 1.3
提问by deepakl.2000
I wrote a conditional if else
tag inside a logic:iterate
in jsp as below:-
我在 jsp 中写了一个条件if else
标签logic:iterate
,如下所示:-
<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:-
我<%@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" %>
When I am opening the jsp file i am getting the following errors. Could you help me in resolving this?
当我打开 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)
回答by Buhake Sindi
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).
您将 Struts 1.3 标签与 Struts 2 标签混合在一起。为了<%@ taglib prefix="s" uri="/struts-tags" %>
编译您的 taglib 声明,您必须struts2-core-2.1.6.jar
在您的WEB-INF\lib
文件夹中包含(撰写本文时最新的 jar),Struts 2struts-tags.tld
位于 (struts2-core-2.1.6.jar\META-INF\struts-tags) 下。 tld)。
Bear in mind that Struts 2 is neverbackward compatible with Struts 1 as it's a completely new architecture Apache has taken new direction from Struts 1.
请记住,Struts 2永远不会与 Struts 1 向后兼容,因为它是一种全新的架构,Apache 从 Struts 1 中采取了新的方向。
I suggest using JSTL instead of using Struts 2 taglib definitions as Struts 1.3 works well with JSTL.
我建议使用 JSTL 而不是使用 Struts 2 taglib 定义,因为 Struts 1.3 可以很好地与 JSTL 配合使用。
回答by Jasonw
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)
在您的部署描述符中,即 web.xml,您应该声明如下内容。(记住在你的 taglib-location 中有 tld 文件)
<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>