BAEL-4404 | Added code to use CharacterEncodingFilter
This commit is contained in:
parent
efd1705136
commit
8febb192a3
|
@ -0,0 +1,27 @@
|
|||
package com.baeldung.charencoding;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.filter.CharacterEncodingFilter;
|
||||
|
||||
@SpringBootApplication
|
||||
public class CharacterEncodingDemo {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CharacterEncodingDemo.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean filterRegistrationBean() {
|
||||
CharacterEncodingFilter filter = new CharacterEncodingFilter();
|
||||
filter.setEncoding("UTF-8");
|
||||
filter.setForceEncoding(true);
|
||||
|
||||
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
|
||||
registrationBean.setFilter(filter);
|
||||
registrationBean.addUrlPatterns("/*");
|
||||
return registrationBean;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.baeldung.charencoding.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
public class CharEncodingCheckController {
|
||||
|
||||
@GetMapping("/ping")
|
||||
public String ping() {
|
||||
return "path";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue