struts 标签 参数

本文介绍了如何在Struts框架中使用request对象进行数据传递,包括设置和获取属性的方法;展示了如何利用html标签进行表单选择操作,并解释了相关属性的作用;此外还提供了一个自定义异常的例子,该异常可以通过国际化配置文件输出错误信息。

1

name 一般是指 request中的属性

因此在request中设置

request.setAttribute("authListResult", authList);

<logic:iterate name="authListResult" id="userInfo" indexId="index">

 

id指 集合中 遍历时 当前的id 相当于在request中添加一个attribute

可以在 jsp中 直接用name使用

<bean:write name="userInfo" property="fullName" />

 

2

property指定值 labelProperty指定显示的项 crmSizeCode 指定选择结果保存的String[] 或者 String (多选/单选)

<html:select property="crmSizeCode" >

<html:options property="crmSizeIds" labelProperty="crmSizeNames"/>

</html:select>

crmSizeCode crmSizeIds  crmSizeNames 都是指request中的一个属性

 

3 自定义一个Exception , 并使用key来输出 国际化信息

public class ErrorException extends Exception {

private String errorCode;
 
public WorkflowException() {
     super();
}

public WorkflowException(String errorCode) {
     super();
     this.errorCode = errorCode;
}
public String getErrorCode(){
     return this.errorCode;
}
public String getErrorMessage(){
  return WFMessageUtil.getMessage(this.errorCode);
}
}

 

public class WFMessageUtil {
 
private static ResourceBundle messageBundle ;
static{
     messageBundle = ResourceBundle.getBundle("WFmessage");//WFmessage:国际化文件
}

public static String getMessage(String errorCode){
     return messageBundle.getString(errorCode);
}

}

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值