java ojnl_java相关:Struts2动态结果集代码示例

java相关:Struts2动态结果集代码示例

发布于 2020-11-30|

复制链接

摘记: 动态结果集可以在action中指定要跳转的页面(${}是OJNL表达式,不是EL表达式)struts.xml:

```xhtml

..

动态结果集可以在action中指定要跳转的页面(${}是OJNL表达式,不是EL表达式)struts.xml:

```xhtml

${r}

```

ResultAction.java:

```java

package cn.edu.hpu.action;

import com.opensymphony.xwork2.ActionSupport;

public class ResultAction extends ActionSupport {

private int type;

private String r="/Hello.jsp";

public int getType() {

return type;

}

public void setType(int type) {

this.type = type;

}

public String getR() {

return r;

}

public void setR(String r) {

this.r = r;

}

public String execute() throws Exception {

//因为r是后来保存在值栈中的,所以能被配置文件以${r}

//的形式读到

if(type==1) r="/User_Add_success.jsp";

else if(type==2) r="/User_Add_error.jsp";

return SUCCESS;

}

}

```

前台链接:

```xhtml

/r/result_mul?type=1" rel="external nofollow" >动态结果集1

/r/result_mul?type=2" rel="external nofollow" >动态结果集2

/r/result_mul?type=3" rel="external nofollow" >动态结果集3

```

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值