This commit is contained in:
xiangwb
2018-03-31 17:33:30 +08:00
parent 747b8c0b00
commit a97ae33afb
4 changed files with 44 additions and 2 deletions
@@ -0,0 +1,29 @@
package com.xwbing.controller.sys;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
/**
* 项目名称: boot-module-demo
* 创建时间: 2018/2/26 14:09
* 作者: xiangwb
* 说明: 登陆首页
*/
@Controller
public class IndexController
{
@RequestMapping("/login")
public ModelAndView login() {
return new ModelAndView("login");
}
@GetMapping("/unauthor")
public String unauthor() {
return "redirect:login";
}
@GetMapping("/index")
public String index() {
return "suecess.html";
}
}
@@ -105,7 +105,7 @@ public class SysUserControl {
@LogInfo("登录")
@ApiOperation(value = "登录", response = RestMessageVo.class)
@PostMapping("login")
@RequestMapping("login")
public JSONObject login(HttpServletRequest request,@RequestParam boolean rememberMe, @RequestParam String userName, @RequestParam String passWord, @RequestParam String checkCode) {
if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(passWord)) {
return JsonResult.toJSONObj("用户名或密码不能为空");
@@ -36,7 +36,9 @@ public class ShiroConfig {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
shiroFilterFactoryBean.setSecurityManager(securityManager());
//如果不设置默认会自动寻找Web工程根目录下的"/login.jsp"页面
shiroFilterFactoryBean.setLoginUrl("/login.html");
shiroFilterFactoryBean.setLoginUrl("/login");
shiroFilterFactoryBean.setSuccessUrl("/index");
shiroFilterFactoryBean.setUnauthorizedUrl("/redirect:unauthor");
Map<String, String> chains = new LinkedHashMap<>();
//静态资源
chains.put("/META-INF/resources/**", "anon");
@@ -58,6 +60,7 @@ public class ShiroConfig {
chains.put("/druid", "anon");
//登录校验
chains.put("/user/login", "anon");
chains.put("/login", "anon");
//权限认证路径
chains.put("/**", "authc");
shiroFilterFactoryBean.setFilterChainDefinitionMap(chains);
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>seccess</title>
</head>
<body>
<h2>seccess</h2>
</body>
</html>