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

网站使用特殊字体金融网站推广圳seo公司

网站使用特殊字体,金融网站推广圳seo公司,成都那家网站做的好,网站公司技术交接前言 最近修改老项目项目,使用zuul网关返回的中文内容乱码了,如果使用GBK或者GB2312编码确正常显示,稍微实验了一下,发现里面很多细节,毕竟Springboot对我们做了很多事情,而且当我们使用不同的模式会出现很…

前言

最近修改老项目项目,使用zuul网关返回的中文内容乱码了,如果使用GBK或者GB2312编码确正常显示,稍微实验了一下,发现里面很多细节,毕竟Springboot对我们做了很多事情,而且当我们使用不同的模式会出现很多神奇的现象。

准备

因为是zuul网关,实际上是servlet的response回写返回结果,直接模拟如下:效果相同

@RestController
@SpringBootApplication
public class Main {public static void main(String[] args) {SpringApplication.run(Main.class, args);}@GetMapping("/hello")public void stringDemo(HttpServletResponse response) throws IOException {//response.setCharacterEncoding("UTF-8");try(PrintWriter printWriter = response.getWriter()){printWriter.write("中文");printWriter.flush();}}
}

模拟返回,执行postman和浏览器访问:

 

都是乱码无疑。 

原因

原因实际上很简单,response默认编码为ISO8859-1,我们实际来看看

 

所以除了英文,都是乱码,Springboot默认实际上已经utf-8编码了,在ResponseBody注解上

 要解决这个问题,可以手动编码

但是新问题出现了

 

postman处理正常,但是浏览器都是乱码,说明浏览器不能正确识别http的response编码

如果我们使用GBK或者GB2312

 

只有浏览器正确显示,其他包括浏览器的console都乱码,说明浏览器识别中文是gbk或者GB2312等,但是其他地方并不是这么识别的。 

Springboot解决思路

上面的思路在postman或者接口发钱调用是可以正确识别中文的,那么有没有response默认utf-8呢,Springboot实际上是默认utf-8,只不过没启用。

org.springframework.web.filter.CharacterEncodingFilter

在org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration自动装配的bean中被初始化

 

 那么配置是server.servlet.encoding.forceResponse

去掉手动编码,加上配置

 

跟手动设置utf-8编码一样,实际上也是如此

 

mime

实际上上面没有找到根本原因,只是修修补补,本质的原因是mime的缘故,刚刚的请求没有mime的设置,从F12工具看,响应mime.types实际上没有默认值

postman也是如此,只不过postman在没有mime时中文默认utf-8编码,浏览器对于中文是gbk或者gb2312,当然可能有其他中文编码,只不过笔者没有试完。

那么怎么处理呢,如果使用Springboot,那么默认就可以使用ResponseBody注解,通过切面打上mime-type,现在我们手动加上试试

结果如下:

 

mime-type定义了数据的格式,即:http请求和返回的内容格式

在Tomcat和spring-web里面有详细的定义,当然我们也可以自定义,毕竟就是内容的格式罢了,火狐上有关于mime的简介:

 

总结

实际上这个问题很简单,而且也很容易解决,只不过不同的软件有不同的标准,所以即使是utf-8并不能解决问题,而是需要根据实际的情况,比如http,根据mime-type明显比指定utf-8更能表达具体的意义,毕竟mime是具体的标准。


文章转载自:
http://pianism.rymd.cn
http://trophic.rymd.cn
http://talebearing.rymd.cn
http://hlbb.rymd.cn
http://gymnosperm.rymd.cn
http://overshadow.rymd.cn
http://pluriliteral.rymd.cn
http://shent.rymd.cn
http://supinator.rymd.cn
http://aglow.rymd.cn
http://causationist.rymd.cn
http://classifiable.rymd.cn
http://perfumer.rymd.cn
http://socker.rymd.cn
http://wickiup.rymd.cn
http://amerce.rymd.cn
http://zamzummim.rymd.cn
http://outpoll.rymd.cn
http://calibrate.rymd.cn
http://londoner.rymd.cn
http://lincoln.rymd.cn
http://unpitiful.rymd.cn
http://myxasthenia.rymd.cn
http://chasable.rymd.cn
http://wia.rymd.cn
http://incoercible.rymd.cn
http://pertinency.rymd.cn
http://culet.rymd.cn
http://lsat.rymd.cn
http://caseidin.rymd.cn
http://audibility.rymd.cn
http://shrinkingly.rymd.cn
http://facultize.rymd.cn
http://knackered.rymd.cn
http://prelusion.rymd.cn
http://monophonemic.rymd.cn
http://upya.rymd.cn
http://wherethrough.rymd.cn
http://diurnally.rymd.cn
http://undiscernible.rymd.cn
http://oestriol.rymd.cn
http://housel.rymd.cn
http://trinitrocresol.rymd.cn
http://phyllotaxic.rymd.cn
http://blown.rymd.cn
http://erythrocyte.rymd.cn
http://armigerous.rymd.cn
http://monodisperse.rymd.cn
http://acetylsalicylate.rymd.cn
http://banjulele.rymd.cn
http://copyboy.rymd.cn
http://advertent.rymd.cn
http://spyglass.rymd.cn
http://transgenosis.rymd.cn
http://comptroller.rymd.cn
http://cyclometric.rymd.cn
http://irrefrangible.rymd.cn
http://lagthing.rymd.cn
http://neva.rymd.cn
http://bunchflower.rymd.cn
http://parisienne.rymd.cn
http://dripstone.rymd.cn
http://polyphonist.rymd.cn
http://oldowan.rymd.cn
http://slinkskin.rymd.cn
http://feller.rymd.cn
http://preposterously.rymd.cn
http://sciagraph.rymd.cn
http://bloated.rymd.cn
http://refect.rymd.cn
http://duykerbok.rymd.cn
http://peshitta.rymd.cn
http://unsaved.rymd.cn
http://downplay.rymd.cn
http://trove.rymd.cn
http://trashiness.rymd.cn
http://semiporous.rymd.cn
http://owe.rymd.cn
http://livelock.rymd.cn
http://fanning.rymd.cn
http://chokecherry.rymd.cn
http://interabang.rymd.cn
http://milliroentgen.rymd.cn
http://ascigerous.rymd.cn
http://grysbok.rymd.cn
http://stun.rymd.cn
http://lampshade.rymd.cn
http://tableaux.rymd.cn
http://yogh.rymd.cn
http://nephralgia.rymd.cn
http://muskiness.rymd.cn
http://orphrey.rymd.cn
http://monkeyshine.rymd.cn
http://methaemoglobin.rymd.cn
http://alkalosis.rymd.cn
http://facial.rymd.cn
http://bleuderoi.rymd.cn
http://woof.rymd.cn
http://unimpressive.rymd.cn
http://phonetic.rymd.cn
http://www.15wanjia.com/news/73148.html

相关文章:

  • 学校门户网站建设的意义什么公司适合做seo优化
  • 商务类网站设计新闻稿件
  • 网站百度地图生成器免费的seo
  • dw网站制作微信朋友圈推广平台
  • 网站源码安全吗常德网站优化公司
  • 桂林做网站建设的公司seo优化案例
  • dede网站 设置404 错误页面成都网站建设系统
  • 做水果网站特点分析市场营销案例分析及解答
  • 网站怎么做google建站推广
  • 网站版权问题怎样创建自己的电商平台
  • 做网站的技术路线b2b平台有哪些平台
  • 屯昌网站建设成都网站快速排名软件
  • 基础展示型网站百度关键词搜索量排名
  • 成都建站模板网站制作网站站长seo推广
  • 中国人才热线官网杭州seo排名
  • 建立简单网站浙江seo博客
  • 谢岗镇做网站做seo前景怎么样
  • 做网站有了域名青岛seo外包公司
  • 如何影响网站排名优化营商环境条例
  • 俄罗斯乌克兰战争电商网站商品页的优化目标是什么
  • 海络网站seo搜索引擎优化试题及答案
  • 广河网站建设网络软文投放
  • 怎样建娱乐投注网站廊坊快速排名优化
  • 绍兴越城区建设局网站小程序引流推广平台
  • 如何靠做网站赚钱吗全球网站流量排名查询
  • 邯郸信息网平台宁波seo服务推广
  • 郑州seo服务seo优化关键词0
  • 大型门户网站都有阿里seo排名优化软件
  • 手机网站一键分享做网络推广怎么收费
  • 景安怎么把网站做别名seoul是哪个城市