我是struts2编程和Web应用程序的新手。我正在学习并关注来自struts2网站的hello world项目。这似乎是直截了当的,但我在运行项目时遇到了很多问题。 以下是我正在使用的材料的链接:http://struts.apache.org/getting-started/hello-world-using-struts2.html 我也通过maven从外部存储库获取罐子
以下是我遇到的错误:
1. [main] ERROR DomHelper:363 - 元素类型“package”的内容必须匹配 “(结果类型?,拦截器?,默认拦截,裁判?,默认动作裁判?,默认级-REF?,全局的结果吗?,全球获准的方法?,全球异常映射?行动*)”。 at(null:18:12)org.xml.sax.SAXParseException:元素的内容 类型“包”必须匹配 “(结果类型?,拦截器?,默认拦截,裁判?,默认动作裁判?,默认级-REF?,全局的结果吗?,全球获准的方法?,全球异常映射?行动*)”。 在 com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) 〜[?:1.8.0_101] at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134) [:?1.8.0_101]
............
2. [main] ERROR Dispatcher:498 - Dispatcher初始化失败com.opensymphony.xwork2.config.ConfigurationException:无法加载 组态。在 com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70) 〜[struts2-core-2.5.10.1.jar:2.5.10.1] at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:906) 〜[struts2-core-2.5.10.1.jar:2.5.10.1] at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)〜[struts2-core-2.5.10.1.jar:2.5.10.1] at at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:486) [struts2-core-2.5.10.1.jar:2.5.10.1] at org.apache.struts2.dispatcher.InitOperations.initDispatcher(InitOperations.java:75) [struts2-core-2.5.10.1.jar:2.5.10.1] at org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:63) [struts2的核 - 2.5.10.1.jar:2.5.10.1]
............ 然后控制台告诉我他们无法加载配置。
这是我的pom文件
http://maven.apache.org/xsd/maven-4.0.0.xsd“> 4.0.0
<groupId>com.certus</groupId>
<artifactId>strutstest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>strutstest</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.5.10.1</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>20030203.000550</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker-gae</artifactId>
<version>2.3.26-incubating</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.22.0-CR1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts.xwork</groupId>
<artifactId>xwork-core</artifactId>
<version>2.3.32</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.8.2</version>
</dependency>
</dependencies>
<build>
<finalName>basic-struts</finalName>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.16.v20140903</version>
<configuration>
<webApp>
<contextPath>/${build.finalName}</contextPath>
</webApp>
<stopKey>CTRL+C</stopKey>
<stopPort>8999</stopPort>
<scanIntervalSeconds>10</scanIntervalSeconds>
<scanTargets>
<scanTarget>src/main/webapp/WEB-INF/web.xml</scanTarget>
</scanTargets>
</configuration>
</plugin>
</plugins>
</build>
这是我的struts文件
<?xml version="1.0" encoding="UTF-8"?>
<constant name="struts.devMode" value="true" />
<package name="strutstest" extends="struts-default">
<action name="index">
<result>/index.jsp</result>
</action>、
<action name="hey" class="com.certus.strutstest.Action.HelloWorldAction" method="execute">
<result name="SUCCESS">/heyyy.jsp</result>
</action>
</package>
我一步一步地按照教程,但我不知道会出现什么问题。如果您看到这些错误,请帮忙。谢谢!