私は春ブーツのために、問題を解決してきました。まず、エンコードされたスラッシュを許可するようにSpringを設定する必要があります。
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Bean
public HttpFirewall allowUrlEncodedSlashHttpFirewall() {
DefaultHttpFirewall firewall = new DefaultHttpFirewall();
firewall.setAllowUrlEncodedSlash(true);
return firewall;
}
@Override
public void configure(WebSecurity web) throws Exception {
web.httpFirewall(allowUrlEncodedSlashHttpFirewall());
}
}
次に、あなたは、組み込みのTomcatからそれを許可する必要があります。
public class Application extends WebMvcConfigurerAdapter {
public static void main(String[] args) {
System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
SpringApplication.run(Application.class, args);
}
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
UrlPathHelper urlPathHelper = new UrlPathHelper();
urlPathHelper.setUrlDecode(false);
configurer.setUrlPathHelper(urlPathHelper);
}
}
これは動作しますが、それを行うための最善の方法は、だけではなく、クエリパラメータを使用することです。
field2に/が含まれている場合、同じURLではありません。それは期待された行動ですか? – Nathan
[スラッシュ(/)?](https://stackoverflow.com/questions/31421061/how-to-handle-requests-that-includes-forward-slashes)を含むリクエストを処理する方法 – ares
これは可能ではありません私のフィールドにはスラッシュをいくつでも入れることができますが、 "/////////////"にすることもできます。 –