读书人

003 - 接收参数_中文有关问题

发布时间: 2012-10-24 14:15:58 作者: rapoo

003 - 接收参数_中文问题
1)接收参数1. 用属性接受参数给Action

?? 注意Action里的属性名就尽量与要传递的属性名相同

(注意不是直接给Action中的同名属性直接赋值)

?

?? 如链接:???? <a href="user/user!add?name=a&age=8">添加用户</a>
?? 它用调UserAction的setName(),和setAge()方法?? 然后再调add()方法

?

相应在struts.xml中的配置:

?,否则会出现下面信息

??System.out.println("age=" + user.getAge());
??return SUCCESS;

??????? System.out.println("age=" + user.getAge());
??????? return SUCCESS;
?}?@Override
?public User getModel() {
??????? return user;
?}}

?

2) 中文问题

在struts.xml中加入?? <constant name="struts.i18n.encoding" value="GBK" />? 即可

?

struts2.1.16 这样加不行,本身的bug

?

另处,constant 中的常量可以在 struts.core.2.1.18.jar引入包?->static文件夹 ->default.properties文件中查到

?

?

读书人网 >软件架构设计

热点推荐