簡體   English   中英

Struts 2 Hello World示例index.jsp 404錯誤

[英]Struts 2 hello world example index.jsp 404 error

我已經完成了谷歌搜索,但是我沒有從那里得到任何幫助。 我正在跟蹤鏈接http://www.tutorialspoint.com/struts_2/struts_examples.htm,並嘗試打開簡單的index.jsp頁面。 這樣做時我收到錯誤

HTTP狀態404-/HelloWorldStruts2/index.jsp


類型狀態報告

消息/HelloWorldStruts2/index.jsp

說明所請求的資源(/HelloWorldStruts2/index.jsp)不可用。


Apache Tomcat / 7.0.12

我的web.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">

   <display-name>Struts 2</display-name>
   <welcome-file-list>
      <welcome-file>index.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="helloworld" extends="struts-default">

     <action name="" 
           >
            <result >/index.jsp</result>
      </action>
      <action name="hello" 
            class="com.tutorialspoint.struts2.HelloWorldAction" 
            method="execute">
            <result name="success">/HelloWorld.jsp</result>
      </action>
   </package>
</struts>

Tomcat堆棧跟蹤:

[![Sep 03, 2015 12:52:39 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.8.0_31\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_31/bin/client;C:/Program Files/Java/jre1.8.0_31/bin;C:/Program Files/Java/jre1.8.0_31/lib/i386;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\IBM\Personal Communications\;C:\Program Files\IBM\Trace Facility\;C:\Program Files\Java\jdk1.8.0_25\bin;C:\Users\456278\Desktop\POI;C:\Eclipse IDE  for Java EE Developers 4.4;;.
Sep 03, 2015 12:52:39 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: \[SetPropertiesRule\]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:HelloWorldStruts2' did not find a matching property.
Sep 03, 2015 12:52:39 PM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler \["http-bio-8080"\]
Sep 03, 2015 12:52:39 PM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler \["ajp-bio-8009"\]
Sep 03, 2015 12:52:39 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 477 ms
Sep 03, 2015 12:52:39 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 03, 2015 12:52:39 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.12
Sep 03, 2015 12:52:39 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using \[SHA1PRNG\] took \[151\] milliseconds.
Sep 03, 2015 12:52:40 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Parsing configuration file \[struts-default.xml\]
Sep 03, 2015 12:52:40 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Unable to locate configuration files of the name struts-plugin.xml, skipping
Sep 03, 2015 12:52:40 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Parsing configuration file \[struts-plugin.xml\]
Sep 03, 2015 12:52:40 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Parsing configuration file \[struts.xml\]
Sep 03, 2015 12:52:40 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Overriding property struts.i18n.reload - old value: false new value: true
Sep 03, 2015 12:52:40 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Overriding property struts.configuration.xml.reload - old value: false new value: true
Sep 03, 2015 12:52:40 PM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler \["http-bio-8080"\]
Sep 03, 2015 12:52:40 PM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler \["ajp-bio-8009"\]
Sep 03, 2015 12:52:40 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1082 ms][1]][1]

我的項目瀏覽器的圖像:

在此處輸入圖片說明

您的index.jsp頁面不在Web內容的根目錄中,而是在WEB-INF ,因此:

<result>/index.jsp</result>

指向不存在的資源。

<result>/WEB-INF/index.jsp</result>

錯誤消息或多或少完全正確。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM