org.apache.jasper.JasperException: /HandlePage.jsp(30,3) Unable to find setter method for attribute: userid(这是什么异常)

haifei123 2007-05-05 12:54:48

-------taglib

package com.item.tag;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTag;
import javax.servlet.jsp.tagext.Tag;

import com.item.bean.ConnectionDatabase;

public class HandleTestPage implements BodyTag
{
private BodyContent body;
private PageContext page;
private String userid;


public void setBookid(String userid)
{
this.userid = userid;
}


public void get()
{
// List data = null;

Connection con = null;
JspWriter out = page.getOut();

try
{
con = ConnectionDatabase.conn();
Statement st = con.createStatement();
String sql = "select * from [firstItem].[dbo].[userManager] where user_id = " + userid;
ResultSet rs = st.executeQuery(sql);
ResultSetMetaData rsmd = rs.getMetaData();
int cols = rsmd.getColumnCount();
out.print("<input type = 'text' name = 'userid' >");
HttpServletRequest request = null;
request.setAttribute("userid", userid);
out.print("<table border=2> <tr>");

for (int i = 1; i < cols + 1; i++)
{
out.print("<th>" + rsmd.getColumnName(i) + "</th>");
}
out.print("</tr>");

while (rs.next())
{
out.print("<tr>");
for (int i = 1; i < cols + 1; i++)
{
out.print("<td>" + rs.getString(i) + "</td>");
}
out.print("</tr>");
}

out.print("</table>");

}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if (con != null)
{
con.close();
}
}
catch (Exception e)
{
e.printStackTrace();
}
}

// return data;
}
public int doStartTag() throws JspException
{
// TODO Auto-generated method stub
if(userid != null)
get();
return this.SKIP_BODY;
}

public int doEndTag() throws JspException
{

return this.EVAL_PAGE;
}
public Tag getParent()
{
return null;
}

public void release()
{
}

public void setPageContext(PageContext arg0)
{

this.page = arg0;
}
public void setBodyContent(BodyContent arg0)
{

this.body = arg0;
}

public void setParent(Tag arg0)
{


}
public void doInitBody() throws JspException
{

}
public int doAfterBody() throws JspException
{
return 0;
}


}


-----jsp

<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%@ taglib uri="www.kengni.com" prefix="p" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'HandlePage.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>
<form name = "from2" action = "#" >


<p:page userid="<%=request.getAttribute("userid") %>"></p:page>

</form>
</body>
</html>
...全文
457 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
awusoft 2007-05-05
  • 打赏
  • 举报
回复
setter method
有一个类没有setUserid()方法啊
haifei123 2007-05-05
  • 打赏
  • 举报
回复
public void setBookid(String userid)
原来我的方法名 写错了
应该写成这样public void setUserid(String userid)

配置文件在解析的时候找不到对应的方法
<attribute>
<name>userid</name>------------这个userid也就是setUserid(String userid)
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧