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

门户网站服务范围百家号关键词排名

门户网站服务范围,百家号关键词排名,呼和浩特建设工程安全管理网站,个人如果做网站赚钱用JAVA进行编写WEB项目时,我们一般需要对WEB进行统一配置,例如制定拦截路径、页面解析器、跨域配置、fastjson报文解析、文件上传大小配置等。 Getter Setter Configuration public class WebConfiguration extends WebMvcConfigurationSupport {priva…

用JAVA进行编写WEB项目时,我们一般需要对WEB进行统一配置,例如制定拦截路径、页面解析器、跨域配置、fastjson报文解析、文件上传大小配置等。

@Getter
@Setter
@Configuration
public class WebConfiguration  extends WebMvcConfigurationSupport {private static final String MATCH_ALL = "/**";@Overridepublic void addInterceptors(InterceptorRegistry registry) {registry.addInterceptor(new RequestIdInterceptor()).addPathPatterns(MATCH_ALL);registry.addInterceptor(new MockRequestEntityInterceptor()).addPathPatterns(MATCH_ALL);}@Overridepublic void addViewControllers(ViewControllerRegistry registry) {registry.addViewController("/").setViewName("index");registry.setOrder(Ordered.HIGHEST_PRECEDENCE);super.addViewControllers(registry);}/** Spring mvc 的页面解析器配置*/@Beanpublic InternalResourceViewResolver viewResolver(){InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();viewResolver.setPrefix("/");viewResolver.setSuffix(".html");return viewResolver;}/*** 跨域配置*/public CorsFilter corsFilter() {UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();source.registerCorsConfiguration("/**", corsConfig());return new CorsFilter(source);}/** Spring mvc 的静态资源路径配置*/@Overridepublic void addResourceHandlers(ResourceHandlerRegistry registry) {registry.addResourceHandler("/resource/**").addResourceLocations("classpath:/static/resource/");registry.addResourceHandler("/*.html").addResourceLocations("classpath:/static/");}/** 项目序列化使用fastjson,因序列化解析器执行是列表由前至后的优先级,故把fastjson加入到序列0的位置*/@Overridepublic void extendMessageConverters(List<HttpMessageConverter<?>> converters) {converters.set(0,fastJsonHttpMessageConverter());}/** 生成FastJsonHttpMessageConverter返回值解析器*/public FastJsonHttpMessageConverter fastJsonHttpMessageConverter() {FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();converter.setFastJsonConfig(fastJsonConfig());converter.setSupportedMediaTypes(mediaTypes());return converter;}/** 生成FastJsonHttpMessageConverter返回值解析器 - 解析详细配置*/public FastJsonConfig fastJsonConfig() {FastJsonConfig fastJsonConfig = new FastJsonConfig();fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat,SerializerFeature.WriteEnumUsingToString);// 日期时间格式及字符集配置fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");fastJsonConfig.setCharset(Charset.forName("utf-8"));// 防止Long类型转json丢失精度的问题SerializeConfig serializeConfig = SerializeConfig.globalInstance;serializeConfig.put(Long.class, ToStringSerializer.instance);serializeConfig.put(Long.TYPE, ToStringSerializer.instance);fastJsonConfig.setSerializeConfig(serializeConfig);return fastJsonConfig;}/** 生成FastJsonHttpMessageConverter返回值解析器 - 解析格式组件 支持的mediaType的类型* 1.application/json;charset=UTF-8* 2.application/json*/public List<MediaType> mediaTypes() {List<MediaType> mediaTypeList = new ArrayList<>();mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8);mediaTypeList.add(MediaType.APPLICATION_JSON);return mediaTypeList;}@Beanpublic CommonsMultipartResolver multipartResolver() {CommonsMultipartResolver resolver = new CommonsMultipartResolver();resolver.setDefaultEncoding("UTF-8");//resolveLazily属性启用是为了推迟文件解析,以在在UploadAction中捕获文件大小异常resolver.setResolveLazily(true);resolver.setMaxInMemorySize(40960);//上传文件大小 5M 5*1024*1024resolver.setMaxUploadSize(5 * 1024 * 1024);return resolver;}private CorsConfiguration corsConfig() {CorsConfiguration corsConfiguration = new CorsConfiguration();corsConfiguration.addAllowedOrigin("*");corsConfiguration.addAllowedHeader("*");corsConfiguration.addAllowedMethod("*");corsConfiguration.setAllowCredentials(true);corsConfiguration.setMaxAge(3600L);return corsConfiguration;}
}

http://www.hkea.cn/news/790390/

相关文章:

  • apk连接wordpress上海seo
  • 企业建网站租用服务器好还是买一个好石家庄网站关键词推广
  • wordpress文件解析外贸网站优化
  • 建设工程竣工备案网站百度保障中心人工电话
  • 韶关城乡建设部网站首页营销型网站建设策划书
  • 建设银行手机银行下载官方网站谷歌浏览器网页版入口在哪里
  • 网站建设 好域名注册信息
  • 公众号微网站建设认证哪个推广网站好
  • 爬取1024上传到wordpress蔡甸seo排名公司
  • 流感吃什么药更好seo的方法
  • 营销型网站建设市场seo黑帽技术有哪些
  • 扬中做网站的公司seo虚拟外链
  • 永川集团网站建设免费网站seo诊断
  • 国外 上海网站建设网络营销推广方式案例
  • 24手表网站网络技术推广服务
  • 鞍山网站制作推广游戏推广员判几年
  • 360如何做网站优化网页设计制作软件
  • 金华网站建设电话电商运营主要负责什么
  • 百度的官方网站游戏推广工作好做吗
  • 著名的深圳网站建设网页快照
  • 政务网站建设要求快速排名软件哪个好
  • 自己网站怎么做优化色盲和色弱的区别
  • 苏州建网站公司seo网络推广培训班
  • 福清市建设局网站石家庄学院
  • 找考卷做要去哪个网站中国国家培训网官网查询
  • 软件系统开发的大概步骤优化网站标题名词解释
  • 院校网站建设模板建站平台
  • 淘宝网站内搜索引擎优化怎么做广告推广平台网站有哪些
  • 大片播放网站国外免费推广网站有哪些
  • flash网站cms排名sem优化软件