大神求救!struts2定义多个action的问题

努力的人运气不会差 2015-08-20 02:38:10
问题:当点击aa的时候,可以成功跳转到success.jsp页面,但是点击bb的时候则报错,这是问什么呢?

下面是我测试的struts.xml、web.xml、index.jsp的文件代码

struts.xml文件

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>

<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />

<package name="default" namespace="/" extends="struts-default">

<action name="aa">
<result>/success.jsp</result>
</action>

<action name="bb">
<result>/success.jsp</result>
</action>

</package>
</struts>


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">
<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>

index.jsp

<%@taglib prefix="s" uri="/struts-tags" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<a href="aa.action">aa</a><br>
<a href="bb.action">bb</a>
</body>
</html>

问题:当点击aa的时候,可以成功跳转到success.jsp页面,但是点击bb的时候则报错,这是问什么呢?

错误信息如下:

There is no Action mapped for namespace [/] and action name [bb] associated with context path [/tetsstruts].
...全文
154 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jollroy 2015-08-21
  • 打赏
  • 举报
回复
引用 5 楼 asd15464654 的回复:
.
把你的struts.priperties 的struts.devMode改为true再测试看看
  • 打赏
  • 举报
回复
各位大神。缓存清了还是不行,用重新解压的tomca发布也还是不行,错误信息如下: Struts Problem Report Struts has detected an unhandled exception: Messages: There is no Action mapped for namespace [/] and action name [bb] associated with context path [/tetsstruts]. Stacktraces There is no Action mapped for namespace [/] and action name [bb] associated with context path [/tetsstruts]. - [unknown location] com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185) org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63) org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37) com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:552) org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) java.lang.Thread.run(Thread.java:724) You are seeing this page because development mode is enabled. Development mode, or devMode, enables extra debugging behaviors and reports to assist developers. To disable this mode, set: struts.devMode=false in your WEB-INF/classes/struts.properties file.
vswen5 2015-08-20
  • 打赏
  • 举报
回复
清一下浏览器缓存,重构下项目,重启下tomcat
浮云疮狗 2015-08-20
  • 打赏
  • 举报
回复
重启tomcat试一下 或许是你加了bb之后没有没有重启tomcat
q99jqhvjyx 2015-08-20
  • 打赏
  • 举报
回复
错误贴出来,另外你清下TOMCAT的缓存,重新发布下试试。
  • 打赏
  • 举报
回复
看不出什么问题 看看吧

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧