模拟有道云笔记

package action;

import java.io.FileWriter;

import org.apache.struts2.ServletActionContext;

import beans.User;

import com.opensymphony.xwork2.ActionSupport;

import dao.UserDAO;

public class AndroidAction   extends ActionSupport {
 
 
 private User user;

 public User getUser() {
  return user;
 }

 public void setUser(User user) {
  this.user = user;
 }
 public String  registerAndroid() throws Exception {
  String username=user.getUsername();
  String password=user.getPassword();
  UserDAO dao=new UserDAO();
  String targetDirectory = ServletActionContext.getServletContext()
     .getRealPath("/");   
  if(dao.findUser(username, password)){
   FileWriter fw=new FileWriter(targetDirectory+"error.html");
     fw.write("error");
     fw.flush();
     fw.close();
   return ERROR;
  }else{
   FileWriter fw=new FileWriter(targetDirectory+"success.html");
    fw.write("success");
    fw.flush();
    fw.close();
    dao.add(user);
  return SUCCESS;
   
  }
  }

}

你可能感兴趣的:(javaee)