java.lang.IllegalArgumentException: Malformed \uxxxx encoding.问题。

由于开发和发布是两套环境,开发是在windows环境下测试,发布环境是linux环境下面,今天在windows上测试的时候发现一个问题,问题如下:
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet.init() for servlet springDispathcher threw exception
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:555)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:619)
root cause

java.lang.IllegalArgumentException: Malformed \uxxxx encoding.
java.util.Properties.loadConvert(Properties.java:552)
java.util.Properties.load0(Properties.java:375)
java.util.Properties.load(Properties.java:325)
org.springframework.util.DefaultPropertiesPersister.load(DefaultPropertiesPersister.java:79)
org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:191)
org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:69)
org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:553)
org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:527)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:362)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
javax.servlet.GenericServlet.init(GenericServlet.java:212)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:555)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:619)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.26 logs.



经过问题分析,找出问题出在

做调用springMVC读取properties文件时报出
java.lang.IllegalArgumentException: Malformed \uxxxx encoding
异常!没有见过!
这个properties文件中配置了文件夹的真实路径,但是java的Properties竟然无法读取!真是郁闷!
g.cn了一下,才发现其中原由,原来java在读取properties文件是遇到\就会出现
java.lang.IllegalArgumentException: Malformed \uxxxx encoding
异常,问题在这里!
仅仅把里面出现的\转换为/就可以了!
回帖的说:
貌似把 \ 换成 \\ 就可以了.
是在JAVA处理文件路径时出现的问题~
跟\没关系,和文件的存储格式有关
不过:
我遇到这个问题是Struts读取资源文件时遇到的,
上面楼主包括回帖的都没看过UTF-8编译后的文件,
里面的非英文字符都是以\u开头,
不可能没有\阿
调查一下原因,如下:
从一个ISO编码的文件里拷的UTF-8编码的内容到资源文件后出异常的,所以这个异常与\和文件存储格式都有关,
建议:
不要把编译后的东西拷来拷去,最好用编译器编译。

你可能感兴趣的:(java,apache,tomcat,Web,servlet)