67,513
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CharactorEncoding</title>
<base href="http://localhost:8080/Structs2_001_domainModel/">
<!-- 注意这里的地址 -->
</head>
<body>
使用domainModel方法来保存参数
<a href="Char/DomainModel!add?user.name=lee&user.age=23">测试</a>
</body>
</html>
....
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/Char" extends="struts-default">
<action name="DomainModel" class="com.lee.structs.UserAction">
<result>
/Test.jsp
</result>
</action>
</package>
....
package com.lee.structs;
import com.opensymphony.xwork2.ActionSupport;
import com.lee.structs.User;
public class UserAction extends ActionSupport {
private User user;
public String add() {
System.out.println("name= " + user.getName());
System.out.println("age= " + user.getAge());
return "success";
}
}
package com.lee.structs;
public class User {
private String name;
private int age;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}