Suman Dhar
Suman Dhar

Reputation: 111

Springmvc RequestMapping accept any character in any language

I need to use a regex in @RequestMapping value so that it can accept Japanese character as well as English character.

I tried this -

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

Its not working while Japanese character present in the URL. But the following is working without Japanese character in request url -

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

What should I put exactly in value attribute to meet my requirements?

Upvotes: 0

Views: 220

Answers (1)

Nguyen Tuan Anh
Nguyen Tuan Anh

Reputation: 1036

I think you should leave the value as it is (i.e. '/Attendance_Report'), like this:

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

In order to accept characters in both English (ISO-8859-1) and Japanese (UTF-8) in the URI, I think it is the matter of the application server (e.g. Tomcat) configuration. For example, if you deploy on Tomcat, you should set the URIEncoding to "UTF-8", like this.

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

Upvotes: 1

Related Questions