Springboot solve garbled garbled and window cmd

 

 @Bean
    public FilterRegistrationBean filterRegistrationBean() { FilterRegistrationBean registration = new FilterRegistrationBean(); CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); characterEncodingFilter.setForceEncoding(true); characterEncodingFilter.setEncoding("UTF-8"); registration.setFilter(characterEncodingFilter); registration.addUrlPatterns("/*"); return registration; } 
This filter is scanned in the main method

note:

application.properties To add the following code, or the code above will not take effect
spring.http.encoding.enabled=false

Second, the character encoding configuration application.properties

spring.http.encoding.enabled=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.force=true

 

#编码格式
spring.http.encoding.force=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
server.tomcat.uri-encoding=UTF-8

  

 

Eventually found, cmd property settings can be modified in the registry, to achieve a modification is always valid:  
1. win + R, type regedit into the registry  
2. Locate the HKEY_CURRENT_USER \ Console \% SystemRoot% _system32_cmd.exe already exists under the CodePage if entry, put the decimal value to "65001"; if not, create a DWORD (32 bit value) in the named "CodePage", the value is set to "65001"  
3. after restarting cmd commencement  
4. for Power shell modify the same, only modified in step 2  
items under% SystemRoot% _system32_WindowsPowerShell_v1.0_powershell.exe.

  

Guess you like

Origin www.cnblogs.com/matd/p/11934464.html