当前位置: 首页 > news >正文

财务公司网站建设婚纱网站页面设计图片

财务公司网站建设,婚纱网站页面设计图片,消防工程师证怎么考,网络业务文章目录 SpringSecurity 返回json一、登录成功处理器1.1 统一响应类HttpResult1.2 登录成功处理器1.3 配置登录成功处理器1.4 登录 二、登录失败处理器2.1 登录失败处理器2.2 配置登录失败处理器2.3 登录 三、退出成功处理器3.1 退出成功处理器3.2 配置退出成功处理器3.3 退出… 文章目录 SpringSecurity 返回json一、登录成功处理器1.1 统一响应类HttpResult1.2 登录成功处理器1.3 配置登录成功处理器1.4 登录 二、登录失败处理器2.1 登录失败处理器2.2 配置登录失败处理器2.3 登录 三、退出成功处理器3.1 退出成功处理器3.2 配置退出成功处理器3.3 退出 四、访问拒绝无权限处理器4.1 访问拒绝处理器4.2 配置访问拒绝处理器4.3 被拒绝 五、自定义处理器 SpringSecurity 返回json 承接1.SpringSecurity -快速入门、加密、基础授权-CSDN博客 一、登录成功处理器 前后端分离成为企业应用开发中的主流前后端分离通过json进行交互登录成功和失败后不用页面跳转而是一段json提示 1.1 统一响应类HttpResult Data AllArgsConstructor NoArgsConstructor Builder public class HttpResult {private Integer code;private String msg;private Object data;public HttpResult(Integer code, String msg) {this.code code;this.msg msg;} }1.2 登录成功处理器 /*** 认证成功就会调用该接口里的方法*/ Component public class AppAuthenticationSuccessHandle implements AuthenticationSuccessHandler {// JSON序列化器进行序列化和反序列化Resourceprivate ObjectMapper objectMapper;;Overridepublic void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { // 定义返回对象httpResultHttpResult httpResult HttpResult.builder().code(200).msg(登陆成功).build();String strResponse objectMapper.writeValueAsString(httpResult);// 响应字符集response.setCharacterEncoding(UTF-8); // 响应内容类型JSON,字符集utf-8response.setContentType(application/json;charsetutf-8); // 响应给前端PrintWriter writer response.getWriter();writer.println(strResponse);writer.flush();} }1.3 配置登录成功处理器 Configuration public class WebSecurityConfig extends WebSecurityConfigurerAdapter {Resourceprivate AppAuthenticationSuccessHandle appAuthenticationSuccessHandle;Overrideprotected void configure(HttpSecurity http) throws Exception {http.authorizeRequests()//授权http请求.anyRequest() //任何请求.authenticated();//都需要认证http.formLogin().successHandler(appAuthenticationSuccessHandle) //认证成功处理器.permitAll();//允许表单登录}}1.4 登录 登录成功后如下所示 二、登录失败处理器 2.1 登录失败处理器 /*** 认证失败就会调用下面的方法*/ Component public class AppAuthenticationFailHandle implements AuthenticationFailureHandler {// JSON序列化器进行序列化和反序列化Resourceprivate ObjectMapper objectMapper;;Overridepublic void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {// 定义返回对象httpResultHttpResult httpResult HttpResult.builder().code(401).msg(登录失败).build();String strResponse objectMapper.writeValueAsString(httpResult);// 响应字符集response.setCharacterEncoding(UTF-8); // 响应内容类型JSON,字符集utf-8response.setContentType(application/json;charsetutf-8); // 响应给前端PrintWriter writer response.getWriter();writer.println(strResponse);writer.flush();} }2.2 配置登录失败处理器 Resource private AppAuthenticationFailHandle appAuthenticationFailHandle;Override protected void configure(HttpSecurity http) throws Exception {http.authorizeRequests()//授权http请求.anyRequest() //任何请求.authenticated();//都需要认证http.formLogin().successHandler(appAuthenticationSuccessHandle) //认证成功处理器.failureHandler(appAuthenticationFailHandle) // 认证失败处理器.permitAll();//允许表单登录 }2.3 登录 输入一个错误的密码 如下图所示 三、退出成功处理器 3.1 退出成功处理器 /*** 退出成功处理器*/ Component public class AppLogoutSuccessHandle implements LogoutSuccessHandler{// JSON序列化器进行序列化和反序列化Resourceprivate ObjectMapper objectMapper;;Overridepublic void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { // 定义返回对象httpResultHttpResult httpResult HttpResult.builder().code(200).msg(退出成功).build();String strResponse objectMapper.writeValueAsString(httpResult);// 响应字符集response.setCharacterEncoding(UTF-8); // 响应内容类型JSON,字符集utf-8response.setContentType(application/json;charsetutf-8); // 响应给前端PrintWriter writer response.getWriter();writer.println(strResponse);writer.flush();} }3.2 配置退出成功处理器 Resource private AppLogoutSuccessHandle appLogoutSuccessHandle;Override protected void configure(HttpSecurity http) throws Exception {http.authorizeRequests()//授权http请求.anyRequest() //任何请求.authenticated();//都需要认证http.formLogin().successHandler(appAuthenticationSuccessHandle) //认证成功处理器.failureHandler(appAuthenticationFailHandle) // 认证失败处理器.permitAll();//允许表单登录http.logout().logoutSuccessHandler(appLogoutSuccessHandle);//登录成功处理器 }3.3 退出 四、访问拒绝无权限处理器 4.1 访问拒绝处理器 Component public class AppAccessDenyHandle implements AccessDeniedHandler {// JSON序列化器进行序列化和反序列化Resourceprivate ObjectMapper objectMapper;;Overridepublic void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {// 定义返回对象httpResultHttpResult httpResult HttpResult.builder().code(403).msg(您没有权限访问该资源).build();String strResponse objectMapper.writeValueAsString(httpResult);// 响应字符集response.setCharacterEncoding(UTF-8); // 响应内容类型JSON,字符集utf-8response.setContentType(application/json;charsetutf-8); // 响应给前端PrintWriter writer response.getWriter();writer.println(strResponse);writer.flush();} }4.2 配置访问拒绝处理器 Resource private AppAccessDenyHandle appAccessDenyHandle;Override protected void configure(HttpSecurity http) throws Exception {http.authorizeRequests()//授权http请求.anyRequest() //任何请求.authenticated();//都需要认证http.formLogin().successHandler(appAuthenticationSuccessHandle) //认证成功处理器.failureHandler(appAuthenticationFailHandle) // 认证失败处理器.permitAll();//允许表单登录http.logout().logoutSuccessHandler(appLogoutSuccessHandle);//登录成功处理器;http.exceptionHandling()//异常处理.accessDeniedHandler(appAccessDenyHandle);//访问被拒绝处理器 }4.3 被拒绝 五、自定义处理器 SpringSecurity - 认证与授权、自定义失败处理、跨域问题、认证成功/失败处理器_我爱布朗熊的博客-CSDN博客
http://www.hkea.cn/news/14425393/

相关文章:

  • 深圳龙岗网站建设培训学校模板建网站
  • 网站从建设到上线流程图如何找做网站的客户
  • 网站建设的关键问题校园网站建设需求
  • 鞍山网站制作云端四川成都网站制作公司
  • 智慧旅游网站建设方案ppt中国建筑网官网测评
  • 手机网站设计属于网页制作平台的是
  • 贵阳专业网站建设公司哪家好wordpress上传的文件在哪
  • 语言教学网站建设课程总结wordpress 导航别名
  • 做网站设计需求wordpress的系统构成图
  • asp建材公司网站源码兼职网站建设收费
  • 网站开发模式名词cdn wordpress ip统计
  • 营销型网站要点购物网站 怎么做
  • 提高网站权重的方法受欢迎的丹阳网站建设
  • 橱柜网站模板云南网站建设维护
  • 电子商务网站建设推广分析网站套网站代码
  • 网站建设犭金手指C排名15东莞网站设计制作网站
  • 怎样做网站后台企业服务网站建设
  • 长安网站建设制作wordpress ajax登录插件
  • 美的集团网站建设方案书做推广哪个平台好
  • 海口网站排名搜索引擎中 哪些网站可以获得更好的排名
  • 网站设计 宽度友情链接交换网站
  • 阿里云申请域名后网站华夏星光工业设计公司
  • 做传销网站后果严重吗中企动力制作的网站
  • 如何给网站做右侧导航英文外贸网站建设
  • .net网站开发代码环保网站建设情况报告
  • wordpress企业网站源码深圳英文网站开发公司
  • 姓氏网站建设的意见和建议青岛网站建设及app
  • 服务网站开发手机有办法做网站吗
  • 建网站 网站内容怎么做谷歌浏览器app
  • 网站建设摘要营销推广方式都有哪些