OGNL表达式:数据类型转换
原始数据类型和包装类的数据类型转换
<body>
<s:form action="login.action" method="POST">
用户名:<s:textfield name="user.name" /><br />
年 龄:<s:password name="user.age" /><br />
<s:submit value="提交" />
</s:form>
</body>
实体类
public class User {
private String name;
private Integer age;
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public Integer getAge() { return age; }
public void setAge(Integer age) { this.age = age; }
}
Action类
public class LoginAction extends ActionSupport {
private User user;
public String execute() throws Exception {
String userName = user.getName();
int age = user.getAge();
user.setName("江河");
user.setAge(32);
return "SUCCESS";
}
public User getUser() { return user; }
public void setUser(User user) { this.user = user; }
}
数组和集合的数据类型转换
我寻见一片海 碧蓝且耀着光
大片船只航行其上 都向着远方
Shared by Foriver_江河