Spring Security里怎么返回登录成功的json消息 5
我的springsecurity3.2的配置如下:<httpauto-config="true"use-expressions="true"><form-loginlog...
我的spring security 3.2的配置如下:
<http auto-config="true" use-expressions="true">
<form-login login-page="/login.jsp" login-processing-url="/login"
username-parameter="username" password-parameter="password"
/>
<access-denied-handler error-page="/403.jsp"/>
<logout invalidate-session="true" logout-url="/logout"
logout-success-url="/" />
<intercept-url pattern="/**" access="permitAll" />
</http>
当我登录成功后,如果想要给前端返回一段json该怎么做。/login貌似是写在框架里的,返回json该怎么做?
自己解决了,
<form-login login-page="/login.jsp" login-processing-url="/login"
username-parameter="username" password-parameter="password"
authentication-success-handler-ref="myAuthenticationSucHandler"
authentication-failure-handler-ref="myAuthenticationFailHandler"
/>
加上authentication-success-handler-ref和authentication-failure-handler-ref
实现AuthenticationFailureHandler 和AuthenticationSuccessHandler
重写里面的方法直接在response中返回即可 展开
<http auto-config="true" use-expressions="true">
<form-login login-page="/login.jsp" login-processing-url="/login"
username-parameter="username" password-parameter="password"
/>
<access-denied-handler error-page="/403.jsp"/>
<logout invalidate-session="true" logout-url="/logout"
logout-success-url="/" />
<intercept-url pattern="/**" access="permitAll" />
</http>
当我登录成功后,如果想要给前端返回一段json该怎么做。/login貌似是写在框架里的,返回json该怎么做?
自己解决了,
<form-login login-page="/login.jsp" login-processing-url="/login"
username-parameter="username" password-parameter="password"
authentication-success-handler-ref="myAuthenticationSucHandler"
authentication-failure-handler-ref="myAuthenticationFailHandler"
/>
加上authentication-success-handler-ref和authentication-failure-handler-ref
实现AuthenticationFailureHandler 和AuthenticationSuccessHandler
重写里面的方法直接在response中返回即可 展开
2个回答
2015-12-08
展开全部
1.0 跳转:
@RequestMapping(value = "/signin", method = RequestMethod.POST)
public String signin(String code, String password, ModelMap model){
return “页面”;
}
@RequestMapping(value = "/signin", method = RequestMethod.POST)
public String signin(String code, String password, ModelMap model){
return “页面”;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询