首页 > 代码库 > javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Invalid property in <set>: "age2"

javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Invalid property in <set>: "age2"

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <base href="http://www.mamicode.com/">         <title>My JSP ‘index.jsp‘ starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0">    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="http://www.mamicode.com/styles.css">-->  </head>     <body><%--   <!-- 静态获取 -->    <c:out value="http://www.mamicode.com/helloworld"></c:out> <!-- 动态获取 --> <% request.getSession().setAttribute("username", "lili");  %> <c:out value="http://www.mamicode.com/${3/2}"></c:out> <% String username="username";  String username1=""; request.setAttribute("username1", username1); //放进requestScope对象里,用EL表达式取 request.setAttribute("username", username);  %>  <!-- false -->  <c:out value="http://www.mamicode.com/${empty username }"></c:out><br>  <!-- true -->  <c:out value="http://www.mamicode.com/${empty username1 }"></c:out><br>  <!-- true -->  <c:out value="http://www.mamicode.com/${empty user }"></c:out><br>  <!-- 使用out标签输出常量 -->  <c:out value="http://www.mamicode.com/hello World"></c:out><br>  <!-- 使用out标签输出变量 -->  <%  request.getSession().setAttribute("name", "li");   %>  <c:out value="http://www.mamicode.com/${name }"></c:out><br>  <!-- default属性的使用 -->  <c:out value="http://www.mamicode.com/${name1 }" default="error"></c:out><br>  <!-- escapeXml="true属性设置是否转义,默认为true不转义-->  <c:out value="http://www.mamicode.com/<out标签>" escapeXml="false"></c:out>    <!-- 表达式控制标签set标签,存值到scope中 -->  <c:set value="http://www.mamicode.com/today" var="day" scope="session"></c:set><br>  <!-- 输出day,值应该是today -->  <c:out value="http://www.mamicode.com/${day }"></c:out>  <!-- 表达式控制标签set标签,存值到scope中 -->  <c:set  var="age" scope="application">eleven</c:set><br>  <!-- 输出day,值应该是today -->  <c:out value="http://www.mamicode.com/${age }"></c:out>     <!-- 存值到javabean中 -->  <!-- 通过set向Person属性赋值 -->  <!-- 赋值和输出都要用EL表达式 --> --%>  <jsp:useBean id="person" class="com.imooc.entity.Person" ></jsp:useBean>  <c:set target="${person}" property="age2"  value="http://www.mamicode.com/12"></c:set><%--   <c:out value="http://www.mamicode.com/${person[age2]}"></c:out> --%>  </body></html>

  如果target="person",如下,会报如题异常!

<c:set target="person" property="age2"  value="http://www.mamicode.com/12"></c:set>

正常写法如下:
<c:set target="${person}" property="age2"  value="http://www.mamicode.com/12"></c:set>

javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Invalid property in &lt;set&gt;: "age2"