双引号中还有双引号的问题
今天在项目中使用jsp:setProperty给类对象赋值,代码如下:
<jsp:useBean id="person" class="com.guan.javabeans.Person" scope="page" />
<jsp:setProperty property="name" name="person" value="潇湘逐梦" />
<jsp:setProperty property="age" name="person" value="23" />
<jsp:setProperty property="sex" name="person" value="男" />
<jsp:setProperty property="married" name="person" value="false" />
<jsp:setProperty property="birthday" name="person"
value="<%=new SimpleDateFormat("yyyy-MM-dd").parse("1989-01-01")%>"/>
<%--使用jsp:getProperty标签获取对象的属性值 --%>
<jsp:getProperty property="name" name="person" />
<jsp:getProperty property="age" name="person" />
<jsp:getProperty property="sex" name="person" />
<jsp:getProperty property="married" name="person" />
<jsp:getProperty property="birthday" name="person" />
运行时报错:请点击这里 错误信息:/jspmark/jspBean4.jsp (line: 38, column: 12) Attribute value new SimpleDateFormat("yyyy-MM-dd").parse("1989-01-01") is quoted with " which must be escaped when used within the value
将上面的标红色的代码改成:value='<%=new SimpleDateFormat("yyyy-MM-dd").parse("1989-01-01")%>'/>
运行成功。