在index.jsp里面导入
<%@taglib prefix="s" uri="/struts-tags" %>
body里面
<s:form namespace="/suserlogin" action="suserlogin" method="post">
用户名:<s:textfield name = "users.username"/>
密码:<s:password name = "users.password"/>
<s:submit value="提交" />
</s:form>
//users要和action里面的属性一致
action
package com.cj.action;
import com.cj.pojo.Users;
import com.opensymphony.xwork2.ActionSupport;
public class SloginAction extends ActionSupport {
private Users users;
public Users getUsers() {
return users;
}
public void setUsers(Users users) {
this.users = users;
}
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
System.out.println("标签属性");
System.out.println(users.getUsername());
System.out.println(users.getPassword());
return "success";
}
}
struts.xml里面
<action name="suserlogin" class="com.cj.action.SloginAction">
<result name="success">/index.jsp</result>
</action>