日期:2014-05-19  浏览次数:20702 次

关于jsp数据提交给本页问题
query.jsp
<%@ page language="java" import="java.util.*,kan.jian.mei.client.*" pageEncoding="GB2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<%@ page contentType="text/html; charset=gb2312"%>
<%
request.setCharacterEncoding("gb2312");

 %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <base href="<%=basePath%>">
   
  <title>My JSP 'query.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>
  <%
  String userName = request.getParameter("userName");
  BookInfoClient qp = new BookInfoClient();
  String BookInfo = qp.getInfoByName(userName);
  out.println(userName);
  %>
  <form name="bookinfo" action="query.jsp" method="post" onsubmit="return false;">
  输入书籍名称:<input type="text" value="<%=userName%>" name="userName"><br><br>
  <input type="submit" value="查询">
  </form>
  <div>
  <br><div><%=BookInfo%></div>
  </div>
  </body>

</html>
我想要实现的功能是输入书籍名称之后点击查询按钮之后div中的bookinfo信息显示出来,可是现在点击根本没有反应,而且bookinfo显示区域一直显示null,我以前貌似解决过类似问题,但是现在好久没用就忘记了,哪位大侠知道帮个忙,十分感谢

------解决方案--------------------
out.println(BookInfo);把
------解决方案--------------------
Java code

<form name="bookinfo" action="query.jsp" method="post" onsubmit="[color=#FF0000]return false[/color];">