日期:2014-05-20  浏览次数:20687 次

为什么不能出结果呢?
有三个文件,都没有报错,但就是运行第一步后在文本框填写东西点提交之后,运行到第二页就总是报错,检查哈没发现什么错误啊。求高手指教,谢了


holleueser.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<jsp:useBean id="mybean" scope="session" class="myjsp.namehander"/>
<jsp:setProperty name="mybean" property="*"/>
<% 
if(request.getParameter("username")!=null){
response.sendRedirect("response.jsp");
}
%>
<%
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>holle.user</title>
  </head>
  
  <body> 
  <h1>Hello,my name is liuyongpo.what is your name?</h1>
  <form method="get" action="holleueser.jsp">
  <input type="text" name="username" size=25><br>
  <input type="submit" value="提交">
  <input type="reset" value="重置">
  </form>
  </body>
</html>


response.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<jsp:useBean id="mybean" scope="session" class="myjsp.namehander"/>
<%
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>Hello,<%=mybean.getname() %></title>
  </head>
  
  <body>
  <h1>Hello,<jsp:getProperty name="mybean" property="username"/></h1>
  </body>
</html>

namehander.java

package myjsp;

public class namehander {

private String username;
public namehander(){
username=null;
}
public void setusername(String name){
username=name;
}
public String getname(){
return username;
}

}



------解决方案--------------------
你把错误贴出来呗