用MyEclipse跟着做出现错误
用MyEclipse跟着做,到通过set标签向person中赋值突然就出现Invalid property in <set>: "name2"错误怎么修改??
用MyEclipse跟着做,到通过set标签向person中赋值突然就出现Invalid property in <set>: "name2"错误怎么修改??
2015-12-15
<%@ 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>
举报