1
我有一個索引jsp。如何從索引頁面向某些bean發送參數,以便第二頁根據發送的參數生成一些數據?如何使用JSP發送參數?
這裏是我的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! qqqqq</h1>
<form name="Input Name Form" action="response.jsp"/>
<p> Enter your name:</p>
<input type="text" name="name"/>
<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>
<h1>Hello World!</h1>
<jsp:useBean id="aaa" scope="page" class="A.a" />
<jsp:setProperty name="aaa" property="name" value="<%= request.getParameter("set")%>" />
<jsp:getProperty name="aaa" property="name" />
</body>
</html>
和我機管局豆:
public class a {
public a()
{}
private String name;
/**
* @return the name
*/
public String get() {
return name;
}
/**
* @param name the name to set
*/
public void set(String name) {
this.name = name;
}
}
GlassFish中說: 組織。 apache.jasper.JasperException:PW C6054:在類型'A.a'的bean中找不到屬性'name'的任何信息。
有什麼問題?爲什麼我的程序不工作?
你嘗試過這麼遠嗎?這是一個非常「鬆散」的問題,需要更簡潔的請求。 – andrewdleach
嚴正....我只是想問是否有可能傳遞一些參數來調用第二頁中的bean。 – Imugi
問題是,它沒有顯示你的努力來解決問題。請參閱[MCVE](http://stackoverflow.com/help/mcve)以獲取有關如何提出良好問題的提示。 – andrewdleach