SSH2整合+分页+ajax+js校验用户名
     1 action:
FriendAction
package com.ipanel.action;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.ServletActionContext;
import com.ipanel.entity.Friend;
import com.ipanel.service.FriendService;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class FriendAction extends ActionSupport {
	private Friend friend;
	private FriendService friendService;
	private String phone;
	private String name;
	private String sex;
	public String getPhone() {
		return phone;
	}	
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public Friend getFriend() {
		return friend;
	}
	public void setFriend(Friend friend) {
		this.friend = friend;
	}
	public FriendService getFriendService() {
		return friendService;
	}
	public void setFriendService(FriendService friendService) {
		this.friendService = friendService;
	}
	// 删除好友
	public String delete() {
		friend = this.friendService.findByName(friend.getName());
		this.friendService.delete(friend);
		return "deletefriend";
	}
	// 添加好友
	public String save() {
		System.out.println(name+";"+phone+";"+sex);
		if(name==null||"".equals(name.trim())){
			this.addFieldError(getName(), "用户名不能为空");
		}else{
			friend = new Friend();
			friend.setName(name);
			friend.setPhone(Integer.parseInt(phone));
			friend.setSex(sex);
		      this.friendService.save(friend);
		}		
        return "save";
	}
//	// 查询好友
//	public String find(Friend friend){
//		friend=this.friendService.findByName(name);
//		return "findfriend";
//	}
//	// 修改好友
//	public String update(Friend friend){
//		friend=this.friendService.findByName(name);
//		friend.setName(name);
//		friend.setPhone(phone);
//		friend.setSex(sex);
//		this.friendService.save(friend);
//           return "save";
//	}
	//验证用户名
	public String checkUserName() throws IOException{  
		HttpServletResponse response = ServletActionContext.getResponse();
		PrintWriter out = response.getWriter();
		System.out.println("jsgfs");
		friend=friendService.findByName(name);
		System.out.println(name);
		if(friend==null)
		{
			out.print(1);
		}
		else
		{
			out.print(0);
		}
		return null;
	}
	@Override
	public String execute() throws Exception {
		return "input";
	}
}
PcookAction
package com.ipanel.action;
import java.io.UnsupportedEncodingException;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.ipanel.entity.Pcook;
import com.ipanel.service.PcookService;
import com.opensymphony.xwork2.ActionSupport;
public class PcookAction extends ActionSupport {
private Pcook pcook;
private PcookService pcookService;
private String name;
private String percent;
private List<Pcook> list;
public String getName() {
	return name;
}
public void setName(String name) {
	this.name = name;
}
public String getPercent() {
	return percent;
}
public