我是JSP的初學者,並試圖做簡單的jsp頁面。我想設置我的班級字段姓名和打印在頁面上。我的等級:JSP Hello Page Error
package org.mypackage.person;
/**
*
* @author cemalinanc
*/
public class Person {
private String name;
private String surname;
Person()
{
name = null;
surname = null;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the surname
*/
public String getSurname() {
return surname;
}
/**
* @param surname the surname to set
*/
public void setSurname(String surname) {
this.surname = surname;
}
}
和我的index.jsp是這樣的:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<form name="input form" action="response.jsp">
Name:
<input type="text" name="name" value="" />
Surname:
<input type="text" name="surname" value="" />
<input type="submit" value="Ok" />
</form>
</body>
</html>
和我的response.jsp頁是這樣的:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<jsp:useBean id="mybean" scope="session" class="org.mypackage.person.Person" />
<jsp:setProperty name="mybean" property="name" />
<h1>Hello, <jsp:getProperty name="mybean" property="name" />!</h1>
</body>
</html>
我只是想設置在這兩個領域班級和打印屏幕兩個,但我不能。後來我試圖打印只是名稱字段,但再次不能。我出現如下錯誤:
服務器遇到內部錯誤(),導致它無法完成此請求。 org.apache.jasper.JasperException:/response.jsp(line:15,column:8)useBean類屬性org.mypackage.person.Person的值無效。
這是什麼問題?
如果你能給我一個想法,我將不勝感激。非常感謝您的幫助。