action在Struts2中做了配置,但是点击超链接的时候没有跳转到指定页面

Mr.Zhang8743 2017-10-27 07:46:43
action类
package zww.com.domain;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;

public class TestActionContextAction {

public String execute(){

System.out.println("success");
return "success";
}

}

struts.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<package name="default" namespace="/" extends="struts-default">
<action name="TestContextAction" class="zww.com.domain.TestActionContextAction"
method="execute">
<result name="success">/test-ContextAction.jsp</result>
</action>


</package>

<!-- 请求参数的编码方式 -->
<constant name="struts.i18n.encoding" value="UTF-8" />
<!-- 指定被struts2处理的请求后缀类型。多个用逗号隔开 -->
<constant name="struts.action.extension" value="action,do,go,qqi" />
<!-- 当struts.xml改动后,是否重新加载。默认值为false(生产环境下使用),开发阶段最好打开 -->
<constant name="struts.configuration.xml.reload" value="true" />
<!-- 是否使用struts的开发模式。开发模式会有更多的调试信息。默认值为false(生产环境下使用),开发阶段最好打开 -->
<constant name="struts.devMode" value="false" />
<!-- 设置浏览器是否缓存静态内容。默认值为true(生产环境下使用),开发阶段最好关闭 -->
<constant name="struts.serve.static.browserCache" value="false" />
<!-- 指定由spring负责action对象的创建 <constant name="struts.objectFactory" value="spring"/> -->
<!-- 是否开启动态方法调用 -->
<constant name="struts.enable.DynamicMethodInvocation" value="false" />

</struts>

点击的页面
<body>
<a href="TestContextAction.action?name=weiwei">testAction</a>
</body>

跳转到的页面
<body>
<h1>TestContextAction</h1>

</body>

...全文
252 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xhn0124 2017-11-09
  • 打赏
  • 举报
回复
如果控制台打印了"success"的画,应该是struts.xml的success跳转的jsp路径没找到?
Mr.Zhang8743 2017-10-27
  • 打赏
  • 举报
回复
我再web.xml文件中做了相应的filter配置,但是还是不行 <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> <init-param> <param-name>config</param-name> <param-value>struts-default.xml,struts-plugin.xml,struts.xml</param-value> </init-param> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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