今天在部署一个项目时,报了这样的异常:
org.apache.jasper.JasperException: Unable to convert string "${topic.postTime}"
to class "java.util.Date" for attribute "value": Property Editor not registered
with the PropertyEditorManager
起初着实不知道是哪里的错.经过几个小时的扎腾才有点端倪.
主要原因是EL表达式无法被解析到.
其实从后台取值并传值到前台来根本就没有错,而前台JSP页面EL表达式无效,解析不到EL表达式,引起的原因是web.xml中:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
maven默认生成的web.xml版本是2.3的,所以有些配置节点idea会识别不出来,因此我们重新添加一个3.1的。
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
还有就是:<%@page isELIgnored="false"%>的优先级要高于web.xml中的设置,所以在JSP中的设置会盖掉web.xml中的设置.