action在Struts2中做了配置,但是点击超链接的时候没有跳转到指定页面
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>
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>
...全文
相关推荐
struts2标签详细讲解
struts2标签详解,详细介绍struts2所有标签,排版整齐,方便阅读,是入门学习的好教程。
Struts2简单的页面跳转示例
初学Struts2,写了一个简单的用struts2实现页面跳转的功能。高手勿喷
Struts2从一个带参数action跳转到另一个action
资源中示例了一个struts2的配置文件中配置的action的result结果为另外一个action的配置,该跳转的过程中是带所有参赛调整的,在另外一个action中可以接受到当前action的所有参数,此配置文件是我日常开发中的经验总结,欢迎各位技术人员下载参考使用
struts2 跳转至404 页面的解决方案
NULL 博文链接:https://rainbow702.iteye.com/blog/2227847
Struts2中实现页面的跳转
解决了跳转no fond 的问题



