IDEA is set to UTF-8) there is one simple bean, that have a regexp, like
private static final String GENERAL_PATTERN_STRING = "^[0-9A-Za-zа-яА-ЯэЭыЫёЁ\\\\/\\s]+$";
I make a build using gradle with encoding properties like
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
But after build is completed successfuly, I deploy .war to Tomcal and try to call start page - i get en error:
Context initialization failed EXCEPTION = [org.springframework.beans.factory.BeanCreationException: Error creating bean with name '...' defined in ServletContext resource
[/WEB-INF/conf/spring/application-context.xml]: Instantiation of bean failed;
.....
java.util.regex.PatternSyntaxException: Illegal character range near index 19
, ^[0-9A-Za-zР°-СЏРђ-РЇСЌРыЫёЁ\\/\s]+$
Where i miss to set the encoding? Any help is appreciated
Well, I don't know where exactly encoding should be configured to solve this. Have never seen it. But I've came across this faq when was looking for the answer. Maybe this can help: https://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q8 And if I had to solve it asap, I would modify the pattern to be "^[\d\p{L}\\\\/\\s]+$" . I feel that this is what the original intention was. Or use UNICODE_CHARACTER_CLASS flag when compile regex pattern, and use widely-known notation "^[\w\\\\/\\s]" - this looks even simpler and much more familiar. I guess, that's the reason why I've never saw that exception and why there's not much info about it on first pages of google: it's more common to use locale-agnostic regex patterns in your code. See more https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html#ucc, https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html#UNICODE_CHARACTER_CLASS
Обсуждают сегодня