开发者

File "/struts-tags" not found in Struts 1.3

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.apach开发者_如何学Goe.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)


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.


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜