我的代码有问题,第一页是这个。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form action="response.jsp">
<h5>Enter your name:</h5>
<input type="text" name="name"/>
<input type="submit" value="OK"/>
</form>
</body>
</html>
当我单击按钮时,表单动作为response.jsp,这是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="mioBean" scope="session" class="test.MyBean" />
<jsp:setProperty name="mioBean" property="name" />
Chiamo la saluta: <%= mioBean.Saluta() %>
<h3>Nome arrivato: <jsp:getProperty name="mioBean" property="name" /> </h3>
</body>
</html>
此代码创建类MyBean的实例,并从该实例调用方法Saluta()。这是MyBean类的代码。
package test;
public class MyBean {
private String name;
public MyBean(){
name = "nessun nome";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String Saluta() {
return "Ciao " + this.name + "!";
}
}
现在,当我单击按钮时,这就是错误。