2014-02-06 38 views
1

我可以在我的代碼中發現一個錯誤,請幫助我處理以下錯誤。無法找到Struts調度程序

在build.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    id="WebApp_ID" version="2.5"> 
    <filter> 
     <filter-name>struts2</filter-name> 
     <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> 
    </filter> 
    <filter-mapping> 
     <filter-name>struts2</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 
    <welcome-file-list> 
     <welcome-file>/index.jsp</welcome-file> 
    </welcome-file-list> 
</web-app> 

的index.jsp

<s:form action="verify"> 

    <s:textfield name="uname" label="Enter Username"/> 
    <s:textfield name="pass" label="Enter the Password"/> 

    <s:submit value="Click" align="center" /> 

</s:form> 

異常

org.apache.jasper.JasperException: The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location] 
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549) 
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470) 
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) 
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 
+0

錯誤表明您直接訪問jsp,嘗試通過操作訪問它們 –

+0

即使您不是新手,也不會直接訪問它,但錯誤並非來自於struts2框架。 –

回答

-1

廣場web.xml文件ü nder WEB-INF文件夾。我也遇到了同樣的問題,但將web.xml文件放在正確的位置解決了問題。