Struts2 之 参数传递(一)
时间:2011-03-08 来源:老高哥
第一种:
类如下:
package com.laogaoge.front;
import com.opensymphony.xwork2.ActionSupport;
public class actionAttiParamInput extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = -5673235011931513331L;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
private String name;
private int age;
public String add(){
System.out.println("name="+name);
System.out.println("age="+age);
return SUCCESS;
}
}
struts.xml的action
<!-- 传递参数 -->
<action name="useraction" class="com.laogaoge.front.actionAttiParamInput" >
<result>
/actionAttiParamInput/actionattiparaminput.jsp
</result>
</action>
jsp中的调用
<a href="front/useraction!add?name=a&age=8">添加用户</a>