The requested resource (/StrutsHelloWorld/) is not

2019-07-26 00:49发布

I'm trying to build my very first struts application using Jboss AS 7 Server. I have the following error after deployed:

HTTP Status 404 - /StrutsHelloWorld/

type Status report

message /StrutsHelloWorld/

description The requested resource (/StrutsHelloWorld/) is not available.
JBoss Web/7.0.13.Final

I followed the guide from http://viralpatel.net/blogs/tutorial-create-struts-2-application-eclipse-example/ and changes my web.xml file on

<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>

I have no deployment error.

the following is my files:

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" 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">

    <display-name>Struts2 Application</display-name>
    <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>
    <welcome-file-list>
        <welcome-file>Login.jsp</welcome-file>
    </welcome-file-list>

</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.enable.DynamicMethodInvocation"
        value="false" />
    <constant name="struts.devMode" value="false" />
    <constant name="struts.custom.i18n.resources"
        value="ApplicationResources" />

    <package name="default" extends="struts-default" namespace="/">
        <action name="login" 
            class="net.viralpatel.struts2.LoginAction">
            <result name="success">Welcome.jsp</result>
            <result name="error">Login.jsp</result>
        </action>
    </package>
</struts>

Jar files:

commons-fileupload-1.3.jar, commons-io-2.0.1.jar, commons-logging-1.1.3.jar, commons-logging-api-1.1.jar, freemarker-2.3.19.jar, ognl-3.0.6.jar, struts-core-2.3.15.1.jar, xwork-core-2.3.15.1.jar

1条回答
Evening l夕情丶
2楼-- · 2019-07-26 01:12

Add the following configuration to your "/" package

<action name="">
  <result>/Login.jsp</result>
</action>

and remove

<welcome-file-list>
    <welcome-file>Login.jsp</welcome-file>
</welcome-file-list>  
查看更多
登录 后发表回答