parent
96e89d2ef6
commit
804e4797a0
@ -0,0 +1,7 @@
|
||||
package com.example.demo.loginService.API;
|
||||
|
||||
import com.example.demo.bean.User;
|
||||
|
||||
public interface UserService {
|
||||
public User selectUserByuserName(String userName);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.example.demo.loginService.API.impl;
|
||||
|
||||
import com.example.demo.Dao.userMapper;
|
||||
import com.example.demo.bean.User;
|
||||
import com.example.demo.loginService.API.UserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service("UserServiceImpl")
|
||||
public class UserServiceImpl implements UserService{
|
||||
private userMapper UserMapper;
|
||||
@Transactional(propagation=Propagation.REQUIRED,readOnly = true)
|
||||
public User selectUserByuserName(String userName){
|
||||
return this.UserMapper.selectUserByuserName(userName);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.example.demo.loginService;
|
||||
|
||||
import com.example.demo.bean.User;
|
||||
import com.example.demo.loginService.API.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
@Controller
|
||||
public class UserController extends HttpServlet{
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@PostMapping("/Login.do")
|
||||
public String doPost1(HttpServletRequest request, HttpServletResponse response){
|
||||
String userName=request.getParameter("userName");
|
||||
String userPwd=request.getParameter("userPwd");
|
||||
User user=this.userService.selectUserByuserName(userName);
|
||||
if(user!=null){
|
||||
if(user.getUserPwd().equals(userPwd)){
|
||||
return "/login1";
|
||||
}
|
||||
else{
|
||||
return "/login2";
|
||||
}
|
||||
}else{
|
||||
return "/login2";
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
spring:
|
||||
mvc:
|
||||
view:
|
||||
prefix: /WEB-INF双击查看原图iews/
|
||||
suffix: .jsp
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:3307/panda?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: 123
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
mybatis:
|
||||
type-aliases-package: com.example.demo.Dao
|
Loading…
Reference in new issue