標籤:request 異常 efi glib 靜態 util lang entity span
<%@ 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="<%=basePath%>"> <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="styles.css">--> </head> <body><%-- <!-- 靜態擷取 --> <c:out value="helloworld"></c:out> <!-- 動態擷取 --> <% request.getSession().setAttribute("username", "lili"); %> <c:out value="${3/2} "></c:out> <% String username="username"; String username1=""; request.setAttribute("username1", username1); //放進requestScope對象裡,用EL運算式取 request.setAttribute("username", username); %> <!-- false --> <c:out value="${empty username }"></c:out><br> <!-- true --> <c:out value="${empty username1 }"></c:out><br> <!-- true --> <c:out value="${empty user }"></c:out><br> <!-- 使用out標籤輸出常量 --> <c:out value="hello World"></c:out><br> <!-- 使用out標籤輸出變數 --> <% request.getSession().setAttribute("name", "li"); %> <c:out value="${name }"></c:out><br> <!-- default屬性的使用 --> <c:out value="${name1 }" default="error"></c:out><br> <!-- escapeXml="true屬性設定是否轉義,預設為true不轉義--> <c:out value="<out標籤>" escapeXml="false"></c:out> <!-- 運算式控制標籤set標籤,存值到scope中 --> <c:set value="today" var="day" scope="session"></c:set><br> <!-- 輸出day,值應該是today --> <c:out value="${day }"></c:out> <!-- 運算式控制標籤set標籤,存值到scope中 --> <c:set var="age" scope="application">eleven</c:set><br> <!-- 輸出day,值應該是today --> <c:out value="${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="12"></c:set><%-- <c:out value="${person[age2]}"></c:out> --%> </body></html>
如果target="person",如下,會報如題異常!
<c:set target="person" property="age2" value="12"></c:set>
正常寫法如下:
<c:set target="${person}" property="age2" value="12"></c:set>
javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Invalid property in <set>: "age2"