#tomcat #struts2
#tomcat #struts2
Вопрос:
Я новичок в struts. У меня возникает ошибка «Запрошенный ресурс недоступен» при запуске моего приложения Struts на tomcat.
Моя структура каталогов:
struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<package name ="user_curd" namespace="/" extends ="struts-default" >
<global-results>
<!-- 下面定义的结果对所有的Action都有效 -->
<result name ="exception"> /error.jsp </result>
</global-results>
<global-exception-mappings>
<!-- 指Action抛出Exception异常时,转入名为exception的结果。 -->
<exception-mapping exception ="java.lang.Exception" result="exception" />
</global-exception-mappings>
<action name ="test" class ="helloworld.TestAction">
</action>
</package>
</struts>
web.xml
<web-app id="MyStrutsApp" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<!--为Struts2定义一个过滤器 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
вывод
J:apache-tomcat-8.0.35bincatalina.bat run
[2016-10-14 09:36:25,278] Artifact ssh_test:war exploded: Server is not connected. Deploy is not available.
Using CATALINA_BASE: "C:Usersm.IntelliJIdea2016.2systemtomcatTomcat_8_0_35_ssh_test"
Using CATALINA_HOME: "J:apache-tomcat-8.0.35"
Using CATALINA_TMPDIR: "J:apache-tomcat-8.0.35temp"
Using JRE_HOME: "F:javajdk"
Using CLASSPATH: "J:apache-tomcat-8.0.35binbootstrap.jar;J:apache-tomcat-8.0.35bintomcat-juli.jar"
14-Oct-2016 21:36:26.572 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.35
14-Oct-2016 21:36:26.573 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: May 11 2016 21:57:08 UTC
14-Oct-2016 21:36:26.573 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.35.0
14-Oct-2016 21:36:26.573 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10
14-Oct-2016 21:36:26.573 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0
14-Oct-2016 21:36:26.573 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
14-Oct-2016 21:36:26.573 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: F:javajdkjre
14-Oct-2016 21:36:26.574 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_77-b03
14-Oct-2016 21:36:26.574 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
14-Oct-2016 21:36:26.574 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:Usersm.IntelliJIdea2016.2systemtomcatTomcat_8_0_35_ssh_test
14-Oct-2016 21:36:26.574 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: J:apache-tomcat-8.0.35
14-Oct-2016 21:36:26.574 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
14-Oct-2016 21:36:26.574 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
14-Oct-2016 21:36:26.574 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
14-Oct-2016 21:36:26.575 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
14-Oct-2016 21:36:26.575 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
14-Oct-2016 21:36:26.575 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
14-Oct-2016 21:36:26.575 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:Usersm.IntelliJIdea2016.2systemtomcatTomcat_8_0_35_ssh_testconflogging.properties
14-Oct-2016 21:36:26.575 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
14-Oct-2016 21:36:26.575 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=J:apache-tomcat-8.0.35endorsed
14-Oct-2016 21:36:26.575 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:Usersm.IntelliJIdea2016.2systemtomcatTomcat_8_0_35_ssh_test
14-Oct-2016 21:36:26.575 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=J:apache-tomcat-8.0.35
14-Oct-2016 21:36:26.575 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=J:apache-tomcat-8.0.35temp
14-Oct-2016 21:36:26.575 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.7 using APR version 1.5.2.
14-Oct-2016 21:36:26.575 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
14-Oct-2016 21:36:27.300 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.2h 3 May 2016)
14-Oct-2016 21:36:27.403 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-apr-8080"]
14-Oct-2016 21:36:27.410 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-apr-8009"]
14-Oct-2016 21:36:27.412 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1082 ms
14-Oct-2016 21:36:27.431 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
14-Oct-2016 21:36:27.431 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.35
14-Oct-2016 21:36:27.441 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
14-Oct-2016 21:36:27.451 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
14-Oct-2016 21:36:27.455 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 42 ms
Connected to server
[2016-10-14 09:36:27,924] Artifact ssh_test:war exploded: Artifact is being deployed, please wait...
14-Oct-2016 21:36:28.887 INFO [RMI TCP Connection(3)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
[2016-10-14 09:36:29,855] Artifact ssh_test:war exploded: Artifact is deployed successfully
[2016-10-14 09:36:29,855] Artifact ssh_test:war exploded: Deploy took 1,931 milliseconds
14-Oct-2016 21:36:37.449 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory J:apache-tomcat-8.0.35webappsmanager
14-Oct-2016 21:36:37.534 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory J:apache-tomcat-8.0.35webappsmanager has finished in 84 ms
Примечание:
1.struts 2.5.2
3.Tomacat 8.0.35
Комментарии:
1. Что за ресурс? Также переведите эти иероглифы в коде на английский.
2. Я решил проблему. Спасибо.
Ответ №1:
Проблема заключается в методе действия. Я добавляю параметр method=»excute» для решения проблемы.
<action name ="test" method="excute" class ="helloworld.TestAction">
Комментарии:
1. У вас опечатка в методе по умолчанию
execute
.