当前位置: 代码迷 >> Java Web开发 >> jasper.JasperException: Attempted a bean operation on a null object.
  详细解决方案

jasper.JasperException: Attempted a bean operation on a null object.

热度:870   发布时间:2016-04-17 01:28:45.0
java usebean
<%@ page contentType="text/html; charset=gb2312" language="java"%>
<html>
<body>
<form name="form1" action="jsp2.jsp" method="post">
<table color="gray">
<caption>学生信息一缆表</caption>
<tr>
<th>学号</th><th>姓名</th><th>性别</th><th>系别</th><th>专业</th><th>籍贯</th>
</tr>
<tr>
<td><input type="text" name="id"></td>
<td><input type="text" name="name"></td>
<td><input type="text" name="sex"></td>
<td><input type="text" name="department"></td>
<td><input type="text" name="speciality"></td>
<td><input type="text" name="hometown"></td>
</tr>
<tr>
<td><input type="submit" value="提交">
</td>
<td><input type="reset" value="重置">
</td></tr>
</table>

</form>

</body>
</html>

<%@ page contentType="text/html; charset=gb2312" language="java" %>
<%@ page import="test.SampleJavaBean4" %>

<html>
<head>

<title>无标题文档</title>
</head>

<body>
<%!
public String ChangeEncoding(String str)
{
String s = str;
try
{
byte tempB[] = s.getBytes("ISO-8859-1");
s = new String(tempB);
return s;
}
catch(Exception e)
{
return s;
}
}
%>
<jsp:useBean id="studentBean" class="test.SampleJavaBean4" scope="request"></jsp:useBean>
<%! String idl,namel,sexl,departmentl,specialityl,hometownl; %>
<%
idl=ChangeEncoding(request.getParameter("id"));
namel=ChangeEncoding(request.getParameter("name"));
sexl=ChangeEncoding(request.getParameter("sex"));
departmentl=ChangeEncoding(request.getParameter("department"));
specialityl=ChangeEncoding(request.getParameter("speciality"));
hometownl=ChangeEncoding(request.getParameter("hometown"));
%>
<jsp:setProperty name="studentBean" property="id" value="<%=idl%>"/>
<jsp:setProperty name="studentBean" property="name" value="<%=namel%>"/>
<jsp:setProperty name="studentBean" property="sex" value="<%=sexl%>"/>
<jsp:setProperty name="studentBean" property="department" value="<%=departmentl%>"/>
<jsp:setProperty name="studentBean" property="speciality" value="<%=specialityl%>"/>
<jsp:setProperty name="studentBean" property="hometown" value="<%=hometownl%>"/>
<jsp:getProperty name="StudentBean" property="id"/>
<jsp:getProperty name="StudentBean" property="name"/>
<jsp:getProperty name="StudentBean" property="sex"/>
<jsp:getProperty name="StudentBean" property="department"/>
<jsp:getProperty name="StudentBean" property="speciality"/>
<jsp:getProperty name="StudentBean" property="hometown"/>
</body>
</html>



org.apache.jasper.JasperException: Attempted a bean operation on a null object.
org.apache.jasper.runtime.JspRuntimeLibrary.handleGetProperty(JspRuntimeLibrary.java:603)
  相关解决方案