主题:jsp向action传值
我用的是SSH框架做的简单的登录,我想把输入的值封装在一个对象当中,然后在action中通过对象的引用获取jsp页面的值,但是总是获取不到,报了个空指针异常,jsp: <form action="user/login.action" method="post">
用户名:<input type="text" id="username" name="Usert2.username" />
密码:<input type="password" id="password" name="Usert2.password" />
<input type="submit" value="登录"/>
action:import com.chinasoft.etc.service.UserService;
import com.opensymphony.xwork2.ActionSupport;
import com.pojo.Usert2;
public class LoginAction extends ActionSupport{
private Usert2 user;
private UserService service;
public Usert2 getUser() {
return user;
}
public void setUser(Usert2 user) {
this.user = user;
}
public UserService getService() {
return service;
}
public void setService(UserService service) {
this.service = service;
}
public String login() throws Exception {
if(service.login(user)){
return super.SUCCESS;
}
else{
return "error";
}
用户名:<input type="text" id="username" name="Usert2.username" />
密码:<input type="password" id="password" name="Usert2.password" />
<input type="submit" value="登录"/>
action:import com.chinasoft.etc.service.UserService;
import com.opensymphony.xwork2.ActionSupport;
import com.pojo.Usert2;
public class LoginAction extends ActionSupport{
private Usert2 user;
private UserService service;
public Usert2 getUser() {
return user;
}
public void setUser(Usert2 user) {
this.user = user;
}
public UserService getService() {
return service;
}
public void setService(UserService service) {
this.service = service;
}
public String login() throws Exception {
if(service.login(user)){
return super.SUCCESS;
}
else{
return "error";
}