Struts 2你好世界的例子index.jsp 404错误

时间:2015-09-03 07:46:59

标签: java jsp tomcat struts2

我完成谷歌搜索但我没有从那里得到任何帮助。 我正在关注链接http://www.tutorialspoint.com/struts_2/struts_examples.htm 并尝试打开简单的index.jsp页面。 这样做我收到错误

  

HTTP状态404 - /HelloWorldStruts2/index.jsp

           

输入状态报告

     

message /HelloWorldStruts2/index.jsp

     

description请求的资源(/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 stacktrace:

[![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]

我的项目资源管理器的图片:

enter image description here

1 个答案:

答案 0 :(得分:0)

您的index.jsp页面不在您的网络内容的根目录,而是位于WEB-INF,所以:

<result>/index.jsp</result>

指向不存在的资源。

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

或多或少与错误消息的确切状态一致。