2016-06-28 66 views
0

我需要在@RequestMapping值中使用正則表達式,以便它可以接受日文字符以及英文字符。Springmvc RequestMapping接受任何語言的任何字符

我想這一點 -

@RequestMapping(value = "/Attendance_Report{[a-z0-9_\\p{Hiragana}\\p{Katakana}]+}", method = RequestMethod.GET) 

它不工作時,日文字符出現在URL中。而下面沒有日文字符工作在請求URL -

@RequestMapping(value = "/Attendance_Report{[a-z0-9_]+}", method = RequestMethod.GET)

我應該把準確的價值屬性,以滿足我的要求?

回答

1

我想你應該離開的價值,因爲它是(即'/Attendance_Report'),像這樣:

@RequestMapping(value = "/Attendance_Report", method = RequestMethod.GET) 

爲了在英語(ISO-8859-1)和日語(UTF-8字符接受)在URI中,我認爲這是應用程序服務器(例如Tomcat)配置的問題。例如,如果您在Tomcat上部署,則應像這樣將URIEncoding設置爲"UTF-8"

<Connector URIEncoding="UTF-8" ..> 
+0

......... ......我試過這個和上面說的RequestMapping。但它給HTTP 400. –

+0

你的請求url是什麼樣的? –