Struts2:对于初学者

时间:2017-08-27 09:20:15

标签: java xml maven intellij-idea struts2

我开始在intellij中使用Struts2。我甚至无法运行我的应用程序,因为每次我从服务器收到此错误:

没有映射名称空间[/]的动作和与上下文路径[]

相关联的动作名称[]

我知道这个问题已经回答了,但我可以解决它。你能帮助我吗?先谢谢,Paolo,这是我的代码。

struts.xml中

<?xml version="1.0" encoding="UTF-8"?>

<package name="Farmacia" extends="struts-default">

    <action name="noActionClass" class="Farmacia" method="perform">
        <result>web/WEB-INF/views/start.jsp</result>
    </action>

</package>

的pom.xml

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd“&GT;     4.0.0

<groupId>groupId</groupId>
<artifactId>Farmacia</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-core</artifactId>
        <version>2.3.1.2</version>
    </dependency>
</dependencies>

<packaging>war</packaging>
<build>
    <finalName>struts-2.3-hello-world-example</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <webXml>web\WEB-INF\web.xml</webXml>
            </configuration>
        </plugin>
    </plugins>
</build>

的web.xml

    <welcome-file-list>
    <welcome-file>start.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>

0 个答案:

没有答案