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

关键词做网站名字百度网站建设多少钱

关键词做网站名字,百度网站建设多少钱,电子商务是干什么的 女生学难吗,网站后台编辑器不显示今天发现spring的异常格式没有跟着mvc的错误格式走#xff0c;场景是用户权限的时候。查了一下原来是springsecurity定义了一组filter作用在了mvc上层#xff0c;因此需要处理一下错误格式。 处理前错误返回信息如下#xff1a; 由于使用了多语言#xff0c;因此错误格式也…今天发现spring的异常格式没有跟着mvc的错误格式走场景是用户权限的时候。查了一下原来是springsecurity定义了一组filter作用在了mvc上层因此需要处理一下错误格式。 处理前错误返回信息如下 由于使用了多语言因此错误格式也要跟着多语言走稍微绕了点弯。配置定义如下 Configuration AutoConfigureBefore({com.xkcoding.justauth.autoconfigure.JustAuthAutoConfiguration.class}) EnableWebSecurity public class SecurityConfigurer extends WebSecurityConfigurerAdapter {private RedissonClient redissonClient;private SecurityExceptionHandler securityExceptionHandler;public SecurityConfigurer(RedissonClient redissonClient, MessageSource messageSource, LocaleResolver localeResolver) {this.redissonClient redissonClient;this.securityExceptionHandler new SecurityExceptionHandler(messageSource, localeResolver);}Overrideprotected void configure(HttpSecurity http) throws Exception {http.authorizeRequests().antMatchers(/GlobalEx.ADMIN_URI_PERFIX/**).authenticated().antMatchers(/GlobalEx.API_URI_PERFIX/**).authenticated().and().addFilterAfter(new JwtHeadFilter(redissonClient), UsernamePasswordAuthenticationFilter.class).sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().exceptionHandling().authenticationEntryPoint(securityExceptionHandler).accessDeniedHandler(securityExceptionHandler).and().csrf().disable();} } 主要是   .and().exceptionHandling().authenticationEntryPoint(securityExceptionHandler).accessDeniedHandler(securityExceptionHandler) 这一段定义了权限解析失败以及没有权限时的错误异常 需要对应的interface处理看了下两个的格式比较接近逻辑代码也接近索性一个类处理了这两种解析 package org.ccframe.commons.auth;import com.alibaba.fastjson.JSON; import lombok.extern.log4j.Log4j2; import org.ccframe.subsys.core.dto.Result; import org.springframework.context.MessageSource; import org.springframework.security.access.AccessDeniedException; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.security.web.access.AccessDeniedHandler; import org.springframework.web.servlet.LocaleResolver;import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.util.Locale;Log4j2 public class SecurityExceptionHandler implements AccessDeniedHandler, AuthenticationEntryPoint{private final Object[] EMPTY_ARGS new Object[0];private final LocaleResolver localeResolver;private final MessageSource messageSource;public SecurityExceptionHandler(MessageSource messageSource, LocaleResolver localeResolver){this.messageSource messageSource;this.localeResolver localeResolver;}private void inner(HttpServletRequest request, HttpServletResponse response, RuntimeException exception, String msgKey) throws IOException {Locale currentLocale localeResolver.resolveLocale(request);String message ;message messageSource.getMessage(msgKey, EMPTY_ARGS, currentLocale); // 未登陆/无权限log.error(message, exception);response.setStatus(HttpServletResponse.SC_FORBIDDEN);response.setHeader(Content-Type,application/json;charsetutf-8);PrintWriter writer response.getWriter() ;writer.write(JSON.toJSONString(Result.error(HttpServletResponse.SC_FORBIDDEN, message, exception.getClass().getName())));writer.flush();writer.close();}Overridepublic void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {inner(request, response, authException, errors.auth.noAuth);}Overridepublic void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {inner(request, response, accessDeniedException, errors.auth.dataNotPermitted);}}对应多语言 运行了一下发现正常了 已经成为我需要的错误返回格式了
http://www.pierceye.com/news/982225/

相关文章:

  • asp.net做网站的步骤网站维护的作用
  • 网站制作前期所需要准备wordpress邮箱配置文件
  • 网站建设网站排名怎么做赣州专业做网站
  • 吉林电商网站建设价格做网站需要每年都缴费吗
  • 怎样用dede搭建网站域名网址
  • 做网站编辑有前途怎么样才算是一个网站页面
  • 建设鲜花网站前的市场分析网店设计理念
  • 网站建设优化服务公司wordpress非代码方式添加备案号
  • asp网站安装到空间教育网站平面设计
  • 快速设计一个网站网站h标签
  • 怎么做百度联盟网站前端面试题
  • 电子商务网站建设的基本要求wordpress提问
  • 论坛网站制作费用wordpress如何调用html代码
  • 打码兔怎么和网站做接口重庆网站建设找承越
  • 做海报的网站什么编辑器微楼书网站建设
  • 免费建站的网站能做影视网站吗深圳网站建设素材网站
  • 网页中网站设计规划流程wordpress主题
  • 贵阳百度做网站电话培训学校
  • 网站关键词推广哪家好深圳方维网络科技有限公司
  • 美工需要的网站阿里云wordpress托管
  • 医疗行业网站建设怎样在网上建立平台
  • 潍坊网站建设网超之梦做的网站后台修改栏目描述
  • 广西建设厅官网证件查询网站优化对企业有什么好处
  • 哪个网站做外贸的多济南建设信息网官网
  • 制作网站能挣钱企业宣传片策划公司
  • 临沂网站建设模板wordpress添加导航页面
  • 有关wordpress教学的网站商标注册号
  • 常用搜索网站浙江立鹏建设有限公司网站
  • 天津做网站优化的公司番禺商城网站建设
  • 网站建设大熊猫点搜营销型网站头部布局的元素