求大神帮助 快一天了,几乎网上所有的方法都试过了,就是没法解决。求解决web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4" id="WebApp_9">
<display-name>Struts Blank</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>
</web-app>struts2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "http://struts.apache.org/dtds/struts-2.3.dtd"
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN">
<struts>
<package name="default" namespace="/" extends="struts-default"> <action name="hello">
<result>
/Hello.jsp
</result>
</action>
</package>
</struts>访问路径:http://localhost:8080/struts2/hello错误代码:
type Status reportmessage There is no Action mapped for namespace [/] and action name [hello] associated with context path [/struts2].description The requested resource (There is no Action mapped for namespace [/] and action name [hello] associated with context path [/struts2].) is not available.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4" id="WebApp_9">
<display-name>Struts Blank</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>
</web-app>struts2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "http://struts.apache.org/dtds/struts-2.3.dtd"
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN">
<struts>
<package name="default" namespace="/" extends="struts-default"> <action name="hello">
<result>
/Hello.jsp
</result>
</action>
</package>
</struts>访问路径:http://localhost:8080/struts2/hello错误代码:
type Status reportmessage There is no Action mapped for namespace [/] and action name [hello] associated with context path [/struts2].description The requested resource (There is no Action mapped for namespace [/] and action name [hello] associated with context path [/struts2].) is not available.
<result name="ok" type="redirect">/state.jsp?err=${err}&mfFileName=${picture}&step=3
</result>
</action>
如果你是直接action进入一个页面,而不做任何业务操作的话,强力建议,如果是管理系统,在对应的权限管理里面直接配置jsp地址。。
action 常规的都会有class 和method,
method="SingleLoginLink">
<result name="success"></result>
</action>还有配置文件呢
<action name="hello">
<result>
/WEB-INF/jsp/error.jsp
</result>
</action>
web.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list> <filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 定义Spring的装载器 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml
</param-value>
</context-param>
<!-- 监听Spring装载器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <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>
</web-app>
struts.xml配置文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<!-- struts2解决编码问题 -->
<constant name="struts.i18n.encoding" value="UTF-8"></constant> <package name="Export" extends="struts-default" namespace="/">
<action name="listArticles" class="incomeInfoAction">
<result name="success">/articleList.jsp</result>
</action>
</package>
</struts>