This commit is contained in:
shuzheng 2016-12-16 18:05:54 +08:00
parent f87a66c95c
commit d64d602bb1
4 changed files with 74 additions and 12 deletions

View File

@ -52,18 +52,6 @@
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- Spring Security -->
<!--
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-->
<!-- Druid连接池监控页面 -->
<servlet>
<servlet-name>DruidStatView</servlet-name>

View File

@ -13,6 +13,10 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
<spring.version>4.3.3.RELEASE</spring.version>
<spring-security.version>4.1.3.RELEASE</spring-security.version>
@ -114,6 +118,11 @@
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.7.5.RELEASE</version>
</dependency>
<!-- 日志 -->
<dependency>
<groupId>org.slf4j</groupId>
@ -191,6 +200,11 @@
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.22</version>
</dependency>
<!-- java mail -->
<dependency>
<groupId>javax.mail</groupId>

View File

@ -0,0 +1,28 @@
package com.zheng.upms.admin.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 示例controller
* Created by shuzheng on 2016/12/16.
*/
@Controller
@RequestMapping("/hello")
public class HelloController {
private static Logger _log = LoggerFactory.getLogger(HelloController.class);
@RequestMapping("")
@ResponseBody
public String index() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date());
}
}

View File

@ -0,0 +1,32 @@
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
<!-- 不需要控制权限的资源 -->
<http pattern="/resources/**" security="none" />
<http use-expressions="false">
<!-- 登录页面不需要控制权限 -->
<intercept-url pattern="/manage/login" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
<!-- 访问其他所有页面都需要有USER权限 -->
<intercept-url pattern="/manage/**" access="ROLE_ADMIN" />
<!-- 登录功能 -->
<form-login login-page="/manage/login" authentication-failure-url="/manage/login?error"/>
<!-- 登出功能 -->
<logout />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<!-- 这里创建两个用户,可以通过用户名密码登录 -->
<user name="admin" password="123456" authorities="ROLE_ADMIN" />
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>