下载NetBeans项目here。文件 - >下载JSTL填充服务器端变量
使用JSTL 1.2我试图让我的web应用程序记住我的输入,然后将它放入输入框中提交表单后,但由于某种原因,它不记得它。我只有1 .java
类和.jsp
文件。
PersonController.java
package controller;
public class PersonController {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
的index.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="controller.PersonController" %>
<jsp:useBean id="personController" class="controller.PersonController" scope="session"/>
<jsp:setProperty name="personController" property="name" param="name"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>PersonController</title>
</head>
<body>
<form method="post" action="index.jsp">
<input name="name" maxlength="30" type="text" id="name" value="<c:out value="${personController.name}"/>"><br/>
<input type="submit" name="button" value="Remember my name">
</form>
</body>
</html>
错误
HTTP状态500 - /index.jsp(行:4,列:0)useBean类属性controller.PersonController的值无效。
如果它没有显示错误#1,那么它将不会填充输入字段
name
与上一个输入发布后。
有什么错误吗? –