Struts2 动态结果集
2024-08-31 04:04:55
1、index.jsp
<body>
动态结果 一定不要忘了为动态结果的保存值设置set get方法
<ol>
<li><a href="user/user?type=1">返回success</li>
<li><a href="user/user?type=2">返回error</li>
</ol>
</body>
2.struts.xml
<struts>
<constant name="struts.devMode" value="true" />
<package name="user" namespace="/user" extends="struts-default">
<action name="user" class="com.wxh.action.UserAction">
<result >${r}</result>
</action>
</package>
</struts>
3.UserAction.java
package com.wxh.action;
import com.opensymphony.xwork2.ActionSupport;
public class UserAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
private int type;
private String r;
public String getR() {
return r;
}
public void setR(String r) {
this.r = r;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
//动态确定r的值
public String execute() throws Exception{
if(type==1) r="/userSuccess.jsp";
else if(type==2) r="/userError.jsp";
return "success";
}
}
4.userError.jsp
<body>
user error!
</body>
5.userSuccess.jsp
<body>
user Success!
</body>
最新文章
- PHP插入header(&#39;content-type:text/html;charset=";utf-8&#39;)和error_reporting()
- SurfaceOutput
- back(返回)键总结
- 防范 DDoS 攻击的 15 个方法
- Svn忽略配置
- Delphi 调试Dll报错 通过GetLastError显示错误信息。
- hdu 2199
- Oracle EBS-SQL (SYS-4):sys_职责查询.sql
- 还是回文(dp)
- PHP-5.5.10+Apache httpd-2.4.9在Windows系统下配置实战
- table中td的宽度不随文字变宽
- 201521123067 《Java程序设计》第6周学习总结
- BZOJ 3512: DZY Loves Math IV [杜教筛]
- linux 值安装yum包
- Microsoft Bot Framework with LUIS
- JAVA 程序编译过程;编辑器,编译器和解释器
- left join 右表数据不唯一的情况解决方法
- pytorch backward问题
- Centos安装gcc及g++
- 每日英语:Marriage makes our children richer — Here&#39;s why