content: package com.andy.action;
  
  import java.io.IOException;
  import java.io.PrintWriter;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.struts2.ServletActionContext;
  
  import com.andy.entity.Teacher;
  import com.andy.service.TeacherService;
  import com.andy.service.TeacherServiceImpl;
  import com.opensymphony.xwork2.ActionSupport;
  
  public class TeacherAddAction extends ActionSupport{
  	private TeacherService teacherService = new TeacherServiceImpl();
  	private String tid;
  	private String tname;
  	private String tsex;
  	private String tlocation;
  	private String tpassword;
  	
  	public String getTid() {
  		return tid;
  	}
  
  	public void setTid(String tid) {
  		this.tid = tid;
  	}
  
  	public String getTname() {
  		return tname;
  	}
  
  	public void setTname(String tname) {
  		this.tname = tname;
  	}
  
  	public String getTsex() {
  		return tsex;
  	}
  
  	public void setTsex(String tsex) {
  		this.tsex = tsex;
  	}
  
  	public String getTlocation() {
  		return tlocation;
  	}
  
  	public void setTlocation(String tlocation) {
  		this.tlocation = tlocation;
  	}
  
  	public String getTpassword() {
  		return tpassword;
  	}
  
  	public void setTpassword(String tpassword) {
  		this.tpassword = tpassword;
  	}
  
  	public void add() throws IOException{
  		HttpServletRequest request = ServletActionContext.getRequest();
  		HttpServletResponse response = ServletActionContext.getResponse();
  		request.setCharacterEncoding("utf-8");
  		response.setCharacterEncoding("utf-8");
  		PrintWriter out = response.getWriter();
  		request.getSession().setAttribute("teacherId", tid);
  		Teacher t = new Teacher(tid,tname,tsex,tlocation,tpassword);
  		if(teacherService.addTeacher(t)){
  			out.print("yes");
  		}else{
  			out.print("no");
  		}
  	}
  }
  