项目结构如图
DeleteControl.代码:
package controls;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import services.UserInfServiceInterface;
@Controller
public class DeleteControl {
@Autowired
private UserInfServiceInterface userInfService;
@RequestMapping("/delete")
public ModelAndView delete(String userid)
{
if(userInfService.delete(userid)==1)
return new ModelAndView("login_success.jsp");
else
return new ModelAndView("login_failure.jsp");
}
}
LoginControl代码:
package controls;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import services.UserInfServiceInterface;
@Controller
public class LoginControl {
@Autowired
private UserInfServiceInterface userInfService;
@RequestMapping("/login")
public ModelAndView login(String userid,String userpwd)
{
if(userInfService.login(userid, userpwd)==1)
return new ModelAndView("login_success.jsp");
else
return new ModelAndView("login_failure.jsp");
}
}
RegisterControl代码
package controls;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import services.UserInfServiceInterface;
@Controller
public class RegisterControl {
@Autowired
private UserInfServiceInterface userInfService;
@RequestMapping("/register")
public ModelAndView login(String userid,String userpwd,String realname)
{
if(userInfService.register(userid, userpwd,realname)==1)
return new ModelAndView("login_success.jsp");
else
return new ModelAndView("login_failure.jsp");
}
}
SelectControl代码
package controls;
import java.io.IOException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import model.UserInf;
import services.UserInfServiceInterface;
@Controller
public class SelectControl {
@Autowired
private UserInfServiceInterface userInfService;
@RequestMapping("/select")
public String select(Model model,String userid) throws IOException {
UserInf user=new UserInf();
user=userInfService.select(userid);
return user.getUserid()+user.getUserpwd()+"selct1";
}
}
UpdateControl代码
package controls;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import model.UserInf;
import services.UserInfServiceInterface;
@Controller
public class UpdateControl {
@Autowired
private UserInfServiceInterface userInfService;
@RequestMapping("/update")
public ModelAndView update(UserInf user)
{
userInfService.update(user);
return new ModelAndView("login_success.jsp");
}
}
UserInfDaoInterface代码
package dao;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import model.UserInf;
public interface UserInfDaoInterface {
@Select("select count(*) from user where userid=#{userid} and userpwd=#{userpwd}")
public int selectByIdPwd(@Param("userid")String userid,@Param("userpwd")String userpwd);
@Insert("insert into user(userid,userpwd,rea