postman shows Content-Type encoding application/json;charset=UTF-8 with utf-8 encoding format
as mentioned, I configured the encoding format in pom.xml. But how to get to controller is still garbled
postman shows Content-Type encoding application/json;charset=UTF-8 with utf-8 encoding format
as mentioned, I configured the encoding format in pom.xml. But how to get to controller is still garbled
your information is not enough, based on the information you give, there is no way to determine which architecture your project uses, either way, you will eventually have to solve the problem of coding formatting.
you can try several options. If you prefer configuration programming, you should add code similar to the following at the top of the web.xml filter
<filter>
<!-- if you want encoding all request, this should be at the top of all your filters -->
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
there is another possibility caused by the maven encoding format, but I don't think it is possible. It probably needs to be configured as follows:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
...
</properties>
if you prefer annotated programming, you can install it in a bean, with the following code:
@Bean public StringHttpMessageConverter stringHttpMessageConverter() {
return new StringHttpMessageConverter(StandardCharsets.UTF_8); //Java 7 imported,
//return new StringHttpMessageConverter(Charset.forName("UTF-8"); //
}
if you are using embedded tomcat, you may need to load a bean, operation as follows:
@Bean public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
tomcat.setUriEncoding("UTF-8");
...
return tomcat;
}
if you are using an external tomcat, I suggest you add coding Filter to the server.xml http or https module (depending on your request protocol). The configuration is roughly as follows:
<connector port="8080" uRIEncoding="utf-8" ... />
as you configured in maven, it is also one of the ways. The code may have spelling or memory problems. Please clap the bricks and correct
.you can take a look at your project's coding set, as well as specify the maven compile-time encoding. Maven defaults to gbk compilation
Previous: How to deal with High concurrency problem with PHP FIFO
Next: How do multiple sibling components in Vue.js share a common component?
write the program for uploading files in java. There is no problem with deployment on other servers in Aliyun. but after deployment in the customer s own server room, my visit to the upload page IE11 reports the following error SCRIPT7002: XMLHttpReq...
for testing and production deployment, just throw the front-end page to nginx but at the time of development, how do you deploy the front-end page? ...
character encoding has been set before getting parameters req.setCharacterEncoding("GB2312"); but it s still garbled ...
web.xml <servlet> <servlet-name>mvc-dispatcher< servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet< servlet-class> <load-on-startup>1< load-on-startup> ...
Today, the server of the program has been changed, and the program can run, and WeChat Pay has no problem, that is, when calling Wechat to stop recording API (wx.stopRecord), fail, Code: function wxRecStop(recNext) { wx.stopRecord({ succe...
the front end uses the vuejs, back end to deploy on the tomcat server using java spring, and the background directory of the request for access to the dist, front end through 8080 is webapp. now there is a problem: visit a top-up page at the front end. ...
the war package is dropped under the webappas directory: ci-0.1.war automatically generates the ci-0.1 directory. run the catalina.sh run access link http: ip:8080 ci-0.1 reported 404 web.xml configuration 1: <Host name="localhost&qu...
I have created a new web project to practice. After web.xml has written the configuration, visit servlet. 500 errors were reported the first time you visited servlet, and 404 errors were reported the second time. first time: : web.xml: ask the gr...
JDK1.7,tomcat8 starts the web3.1maven project to report an error Could not resolve XML resource [null] with public ID as mentioned! Tomcat7 certainly can not be used, 8 words to report this mistake, inexplicable! ...
is when I created a new web project for maven, what I found on the official website was tomcat7-maven-plugin s dependency pluginplugin Why are we allowed to add in dependencies? ...
The log of tomcat can be printed normally when it is just started. After a few days of normal operation of the system (the time is uncertain), there will be a lack of log printing or log printing, but the system can still be used normally. Log printing ...
an error is reported when starting using tomcat. The following is the error message: 31-May-2018 09:48:14.910 [RMI TCP Connection(7)-127.0.0.1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: org.apache.catalin...
if there is a set of operations to be performed within a method that belongs to the same transaction, how is the transaction in progress handled when tomcat closes? Will tomcat wait for the transaction to finish? Or does the transaction become incomplete...
the www.abc.com domain name is resolved on the server. It is configured in tomcat and can be transferred to the home page directly through the domain name. later asked that abc.com can also achieve input jump, what are the ways to achieve it. It doesn ...
is there any way to know clearly whether the service in tomcat has been started and completed? because the tomcat will first occupy the port when it starts, but the service of the corresponding port has not been fully started when the tomcat occupies th...
problem description Project editing can be deployed under tomcat, but cannot be started under idea use the platform fedora 28 Idea 2017.1 tomcat 8.5.21 JDK 1.8 reporting information 30-Jul-2018 16:18:27.474 [RMI TCP Connection(2)-127.0.0.1]...
problem description list binds data components to loop out three messages, all of which have a separate checkbox, placed under the same level div of checkbox, and list. How to use checkbox under div to achieve all deselect functions. There is no way...
problem description use web wap to add UnionPay payment function to bex5 the platform version of the problem and what methods you have tried bex5_V3.8, has no clue, related codes Please paste the code text below (do not replace the code wi...
problem description When webService passes special characters such as , , ", etc., it is automatically escaped by the frame to . what result do you expect? What is the error message actually seen? is there any way to avoid the problem of automati...
the project packages the dist file. After it is deployed to tomcat, it cannot be accessed. Change the of assetsPublicPath to . , the project can be accessed normally, but the picture always cannot be displayed . build parameters Template ...