请问 我怎样把 jsp页面中从数剧库 查找到的参数 传到 javabean 如下 我用的是session 但不可以<%
String strPage = request.getParameter("Page");
String strSql = "";
ObjDBConnBean = com.goldgrid.DBConnBean.getInstance();
Connection Conn = ObjDBConnBean.getConnection("goa");
Statement stmt = null;
try {
String strPlacard_No = new String(request.getParameter("SelectedItems").getBytes("8859_1"));
stmt = Conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
session.setAttribute("strPlacard_No1",strPlacard_No);
strSql = "SELECT * FROM [Forum] WHERE Placard_No = '"+strPlacard_No+"'";//显示发布的帖子
rs = stmt.executeQuery(strSql);
//int count=rs.getInt("d_count");
// count++;
if (rs.next()){
int count=rs.getInt("d_count");
count++;
String cishuo=String.valueOf("count");
session.setAttribute("count",cishuo);
session.setAttribute("title0",(String)rs.getString("title"));
session.setAttribute("description0",(String)rs.getString("description"));
%>
然后我就在bean里用 String stPlacard_No ="<%=(String)session.getAttribute('count')%>";调用 但不行 帮帮 谢谢
String strPage = request.getParameter("Page");
String strSql = "";
ObjDBConnBean = com.goldgrid.DBConnBean.getInstance();
Connection Conn = ObjDBConnBean.getConnection("goa");
Statement stmt = null;
try {
String strPlacard_No = new String(request.getParameter("SelectedItems").getBytes("8859_1"));
stmt = Conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
session.setAttribute("strPlacard_No1",strPlacard_No);
strSql = "SELECT * FROM [Forum] WHERE Placard_No = '"+strPlacard_No+"'";//显示发布的帖子
rs = stmt.executeQuery(strSql);
//int count=rs.getInt("d_count");
// count++;
if (rs.next()){
int count=rs.getInt("d_count");
count++;
String cishuo=String.valueOf("count");
session.setAttribute("count",cishuo);
session.setAttribute("title0",(String)rs.getString("title"));
session.setAttribute("description0",(String)rs.getString("description"));
%>
然后我就在bean里用 String stPlacard_No ="<%=(String)session.getAttribute('count')%>";调用 但不行 帮帮 谢谢
bean能这样子用?
你可以在BEAN中连接数据库
取出参数,然后存到BEAN中
在调用BEAN时再取出来