2016-02-19 143 views
1

需要幫助來運行示例struts程序,它引發「請求的資源不可用」錯誤。struts錯誤:請求的資源不可用

我用struts-2.3.24.1和Tomcat 8.

The Project structure

web.xml中:

<?xml version="1.0" encoding="UTF-8"?> 
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> 

     <display-name>SampleStruts</display-name> 
     <welcome-file-list> 
     <welcome-file>login.jsp</welcome-file> 
     </welcome-file-list> 

     <filter> 
      <filter-name>struts2</filter-name> 
      <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 
     </filter> 

     <filter-mapping> 
      <filter-name>struts2</filter-name> 
      <url-pattern>/*</url-pattern> 
     </filter-mapping> 

    </web-app> 

struts.xml的

<?xml version="1.0" encoding="UTF-8"?> 
    <!DOCTYPE struts PUBLIC 
     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" 
     "http://struts.apache.org/dtds/struts-2.0.dtd"> 

     <struts> 
      <constant name="struts.devMode" value="true" /> 
      <package name="default" namespace="/" extends="struts-default"> 
      <action name="login" class="com.sr.actions.LoginAction" > 
       <result name="success"> /welcome.jsp </result> 
       <result name="failed"> /failed.jsp </result> 
      </action> 
     </package> 

     </struts> 

請讓我知道如何解決這個問題。

+0

'struts.xml'文件必須位於類路徑的根目錄下。 –

回答

1

不一致的庫依賴性依賴管理中最常見的錯誤。您在項目依賴關係中沒有重要的庫。

需要commons-lang3-3.1.jar來解決錯誤。

請參閱如何Create Struts application using Maven

+0

謝謝..現在login.jsp正在打開。但是在提交頁面時會拋出錯誤:沒有爲名稱空間[/]映射的操作和與上下文路徑[/ SampleStruts]關聯的操作名稱[登錄]。 – soumya

+0

將'struts.xml'移動到'src'文件夾。 –

+0

它的工作..謝謝你.. :) – soumya