我对url编码有问题。我想将静态编码的url(例如“%2FWEB-INF%2Fviews%2Fjsp%2Fhello”)作为请求变量发送到spring mvc,但我无法处理此请求。有人建议吗?
最佳答案
如果使用spring,则在@Configuration
文件之一中的bean下面进行初始化:
@Bean
public FilterRegistrationBean filterRegistrationBean() {
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
characterEncodingFilter.setForceEncoding(true);
characterEncodingFilter.setEncoding("UTF-8");
registrationBean.setFilter(characterEncodingFilter);