SpringSecurity实现后台管理员登录(二)

需求:login.ftl页面中登录成功后进入index.ftl页面中

 

一、pom.xml中添加json转换相关的包

 

[html]  view plain  copy
 
 在CODE上查看代码片派生到我的代码片
  1. <dependency>  
  2.     <groupId>com.fasterxml.jackson.core</groupId>  
  3.     <artifactId>jackson-core</artifactId>  
  4.     <version>2.4.4</version>  
  5. </dependency>  
  6. <dependency>  
  7.     <groupId>com.fasterxml.jackson.core</groupId>  
  8.     <artifactId>jackson-databind</artifactId>  
  9.     <version>2.4.4</version>  
  10. </dependency>  
  11. <dependency>  
  12.     <groupId>com.fasterxml.jackson.core</groupId>  
  13.     <artifactId>jackson-annotations</artifactId>  
  14.     <version>2.4.4</version>  
  15. </dependency>  

 

 

二、applicationContext-mvc.xml中添加json转换相关的配置

 

[html]  view plain  copy
 
 在CODE上查看代码片派生到我的代码片
  1. <!--token 拦截校验 -->  
  2. <mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" />  
  3. <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">  
  4.     <property name="favorPathExtension" value="false" />  
  5.     <property name="favorParameter" value="true" />  
  6.     <property name="ignoreAcceptHeader" value="false" />  
  7.     <property name="mediaTypes">  
  8.         <value>  
  9.             atom=application/atom+xml  
  10.             html=text/html  
  11.             json=application/json  
  12.             *=*/*  
  13.         </value>  
  14.     </property>  
  15. </bean>  

 

 

三、applicationContext-security.xml中

将<intercept-url pattern="/service/index/index"access="ROLE_AUTHORITY"/>

改为<intercept-url pattern="/service/index/index" />

 

这里只是要实现简单的登录功能,所以没有设计权限。加了access=” "ROLE_AUTHORITY”会导致无法登录。

 

四、实现效果

 

转载于:https://www.cnblogs.com/grimm/p/6732866.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值