struts2复习记录__简单登录
今日复习,发现好多知识点都已经很是模糊,决定以后认真复习,并记录之。---struts2登录---1、strust.xml内容:<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"><struts><package name="defualt" namespace="/" extends="struts-default"><action name="login" method="post"><table border="1" cellpadding="0" cellspacing="0" bordercolor="red"><tr><td>用户名</td><td><input type="text" name="username" /></td></tr><tr><td>密 码</td><td><input type="password" name="password" /></td></tr><tr><td colspan="2" align="right"><input type="submit" value="login" /></td></tr></table></form></body>3、LoginAction.java内容:package com.he.action;import com.opensymphony.xwork2.Action;import com.opensymphony.xwork2.ActionContext;import com.opensymphony.xwork2.ActionSupport;public class LoginAction extends ActionSupport{private String username ;private String password ;public String getUsername(){return username;}public void setUsername(String username){this.username = username;}public String getPassword(){return password;}public void setPassword(String password){this.password = password;}public String execute() throws Exception{if(!username.equals("")&&!password.equals("") ){ActionContext.getContext().getSession().put("username", username);return Action.SUCCESS ;}else{return Action.INPUT ;}}}