在以前的几个项目中(所有Spring-3.0之前的版本),我有一个错误处理jsp文件(通常是"message.jsp"),其中有一行类似于以下内容:
<spring:message code="exceptions.${exception.class.name}" text="${exception.message}"/>
Run Code Online (Sandbox Code Playgroud)
这允许我将异常映射到此页面,并通过定义SimpleMappingExceptionResolver的派生,根据异常类型解决某些本地化错误消息:
<bean id="exceptionMapping" class="mycode.ui.resolvers.MyExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="java.lang.Exception">message</prop>
<prop key="javax.servlet.ServletException">message</prop>
<prop key="MyCustomException">message</prop>
<prop key="ApplicationAuthorizationException">login</prop>
<prop key="NotLoggedInException">login</prop>
</props>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
这个工作完美无缺,直到我尝试升级到Spring 3和Tomcat 7.现在,当我使用这段代码时,我收到以下错误:
"${exception.class.name}" contains invalid expression(s): javax.el.ELException: The identifier [class] is not a valid Java identifier as required by section 1.19 of the EL specification
Run Code Online (Sandbox Code Playgroud)
知道改变了什么或如何访问异常的类名(Spring返回到映射错误页面的模型的一部分)?
我收到以下错误:
SEVERE: Servlet.service() for servlet jsp threw exception
javax.el.ELException: The identifier [case] is not a valid Java identifier as required by section 1.19 of the EL specification (Identifier ::= Java language identifier). This check can be disabled by setting the system property org.apache.el.parser.SKIP_IDENTIFIER_CHECK to true.
Run Code Online (Sandbox Code Playgroud)
这是由于在tomcat 7默认情况下SKIP IDENTIFIER CHECK功能是假的(在tomcat 6及以下版本中都是如此)我在正则表达式中使用"case"而case是标识符所以它会抛出错误.
我找到了以下解决方案: javax.el.ELException:标识符[return]不是有效的Java标识符
但它对我不起作用,因为我不想在我的代码中进行更改.所以我想要解决方案将tomcat 7配置为SKIP IDENTIFIER CHECK为true.
即使经过大量的谷歌搜索,我也没有办法做到这一点.我正在使用eclipse juno和tomcat 7,请帮我看看.