这是一个简单的Struts1登录应用程序。我是新手struts用户。 MySrutsApp无法找到ActionServlet(http-404错误)。显然,web.xml和struts-config.xml
存在问题。
请找我的错误。
My web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>MyStrutsApp</display-name>
<servlet>
<servlet-name>frontcontroller</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>frontcontroller</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>Login.html</welcome-file>
</welcome-file-list>
</web-app>
My struts-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<!-- Form Beans Configuration -->
<form-beans>
<form-bean name="somename" type="com.sanket.login.LoginFormBean"/>
</form-beans>
<!-- Golbal Forwards -->
<!-- Action Mapping Configuration -->
<action-mappings>
<action path="/Login.html" type="com.sanket.login.LoginAction" name="somename" validate="false" input="/.Login.html">
<forward name="success" path="/success.html"/>
<forward name="failure" path="/failure.html"/>
</action>
</action-mappings>
</struts-config>
面对的错误:
Oct 03, 2014 11:06:05 AM 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\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\oraclexe\app\oracle\product\11.2.0\server\bin;;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.7.0_65\bin;E:\eclipse;;.
Oct 03, 2014 11:06:05 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:MyStrutsApp' did not find a matching property.
Oct 03, 2014 11:06:05 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8085"]
Oct 03, 2014 11:06:05 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Oct 03, 2014 11:06:05 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 547 ms
Oct 03, 2014 11:06:05 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Oct 03, 2014 11:06:05 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.27
Oct 03, 2014 11:06:05 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [117] milliseconds.
Oct 03, 2014 11:06:05 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Users\Pargaonkar\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\MyStrutsApp\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Oct 03, 2014 11:06:05 AM org.apache.struts.action.ActionServlet initChain
INFO: Loading chain catalog from jar:file:/C:/Users/Pargaonkar/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/MyStrutsApp/WEB-INF/lib/struts-core-1.3.10.jar!/org/apache/struts/chain/chain-config.xml
Oct 03, 2014 11:06:06 AM org.apache.struts.util.PropertyMessageResources loadLocale
WARNING: Resource org/apache/struts/action/ActionResources_en_US.properties Not Found.
Oct 03, 2014 11:06:06 AM org.apache.struts.util.PropertyMessageResources loadLocale
WARNING: Resource org/apache/struts/action/ActionResources_en.properties Not Found.
Oct 03, 2014 11:06:06 AM org.apache.struts.action.ActionServlet splitAndResolvePaths
SEVERE: Missing configuration resource for path WEB-INF/struts-config.xml
Oct 03, 2014 11:06:06 AM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet frontcontroller as unavailable
Oct 03, 2014 11:06:06 AM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /MyStrutsApp threw load() exception
javax.servlet.UnavailableException: Missing configuration resource for path WEB-INF/struts-config.xml
at org.apache.struts.action.ActionServlet.splitAndResolvePaths(ActionServlet.java:1872)
at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:683)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:356)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Oct 03, 2014 11:06:06 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8085"]
Oct 03, 2014 11:06:06 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Oct 03, 2014 11:06:06 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 827 ms
Oct 03, 2014 11:06:10 AM org.apache.catalina.core.StandardWrapperValve invoke
INFO: Servlet frontcontroller is currently unavailable
Oct 03, 2014 11:19:09 AM org.apache.catalina.core.StandardWrapperValve invoke`enter code here`
INFO: Servlet frontcontroller is currently unavailable
答案 0 :(得分:1)
您应该在配置文件位置之前有一个前导/
,例如
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>