我做的个bbs ,点提交没反应是怎么回事呀,求助?
reply.jsp页面<%@page pageEncoding="GB18030"%>
<%@page import="java.sql.*, com.bjsxt.bbs.*" %>
<%
int id = Integer.parseInt(request.getParameter("id"));
int rootId = Integer.parseInt(request.getParameter("rootId"));
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Java|Java世界_中文论坛|ChinaJavaWorld技术论坛 : 初学java遇一难题!!望大家能帮忙一下 ...</title>
<meta http-equiv="content-type" content="text/html; charset=GBK">
<link rel="stylesheet" type="text/css" href="images/style.css" title="Integrated Styles">
<script language="JavaScript" type="text/javascript" src="images/global.js"></script>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://bbs.chinajavaworld.com/rss/rssmessages.jspa?threadID=744236">
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td width="140"><a href="http://bbs.chinajavaworld.com/index.jspa"><img src="images/header-left.gif" alt="Java|Java世界_中文论坛|ChinaJavaWorld技术论坛" border="0"></a></td>
<td><img src="images/header-stretch.gif" alt="" border="0" height="57" width="100%"></td>
<td width="1%"><img src="images/header-right.gif" alt="" border="0"></td>
</tr>
</tbody>
</table>
<br>
<div id="jive-flatpage">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr valign="top">
<td width="99%"><p class="jive-breadcrumbs"> <a href="http://bbs.chinajavaworld.com/index.jspa">首页</a> » <a href="http://bbs.chinajavaworld.com/forumindex.jspa?categoryID=1">ChinaJavaWorld技术论坛|Java世界_中文论坛</a> » <a href="http://bbs.chinajavaworld.com/category.jspa?categoryID=2">Java 2 Platform, Standard Edition (J2SE)</a> » <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=0">Java语言*初级版</a> </p>
<p class="jive-page-title"> 主题: reply</p></td>
<td width="1%"><div class="jive-accountbox"></div></td>
</tr>
</tbody>
</table>
<div class="jive-buttons">
<table summary="Buttons" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="jive-icon"><a href="http://bbs.chinajavaworld.com/post%21reply.jspa?threadID=744236"><img src="images/reply-16x16.gif" alt="回复本主题" border="0" height="16" width="16"></a></td>
<td class="jive-icon-label"><a id="jive-reply-thread" href="reply.jsp">回复本主题</a> </td>
</tr>
</tbody>
</table>
</div>
<br>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr valign="top">
<td width="99%"><div id="jive-message-holder">
<div class="jive-message-list">
<div class="jive-table">
<div class="jive-messagebox">
<from action="replyDeal.jsp" method="post">
<input type="hidden" name="pid" value="<%=id %>"/>
<input type="hidden" name="rootId" value="<%=rootId %>"/>
标题:<input type="text" name="title"><br>
内容:<textarea name="cont" rows="15" cols="80"></textarea>
<br>
<input type="submit" value="提交" class="button">
</from>
</div>
</div>
</div>
<div class="jive-message-list-footer">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td nowrap="nowrap" width="1%"></td>
<td align="center" width="98%"><table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td><a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20"> <img src="images/arrow-left-16x16.gif" alt="返回到主题列表" border="0" height="16" hspace="6" width="16"></a> </td>
<td><a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20">返回到主题列表</a> </td>
</tr>
</tbody>
</table></td>
<td nowrap="nowrap" width="1%"> </td>
</tr>
</tbody>
</table>
</div>
</div></td>
<td width="1%"></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
replyDe.jsp页面
<%@ page language="java" import="java.util.*, java.sql.*, com.bjsxt.bbs.*" pageEncoding="GB18030"%>
<%
request.setCharacterEncoding("GBK");
int id = Integer.parseInt(request.getParameter("pid"));
int rootId = Integer.parseInt(request.getParameter("rootId"));
String title = request.getParameter("title");
System.out.println(title);
String cont = request.getParameter("cont");
System.out.println(cont);
connection c = DB.getConn();
String sql = "insert into article values (null, ?, ?, ?, ?, now(), ?)";
PreparedStatement pstmt = DB.prepareStmt(conn, sql);
pstmt.setInt(1, pid);
pstmt.setInt(2,rootId);
pstmt.setString(3, title);
pstmt.setString(4, cont);
pstmt.setInt(5, 0);
pstmt.executeUpdate();
DB.close(pstmt);
DB.close(conn);
%>
<%
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 'MyJsp.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>
恭喜您,回复完成!! <br>
</body>
</html>
Artical.java
package com.bjsxt.bbs;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
public class Article {
private int id;
private int pid;
private int rootId;
private String title;
private String cont;
private Date pdate;
private int grade;
private boolean isLeaf;
public boolean isLeaf() {
return isLeaf;
}
public void setLeaf(boolean isLeaf) {
this.isLeaf = isLeaf;
}
public Date getPdate() {
return pdate;
}
public void setPdate(Date pdate) {
this.pdate = pdate;
}
public int getRootId() {
return rootId;
}
public void setRootId(int rootId) {
this.rootId = rootId;
}
public int getGrade() {
return grade;
}
public void setGrade(int grade) {
this.grade = grade;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getCont() {
return cont;
}
public void setCont(String cont) {
this.cont = cont;
}
public void initFromRS(ResultSet rs){
try{
setId(rs.getInt("id"));
setPid(rs.getInt("pid"));
setRootId(rs.getInt("rootid"));
setTitle(rs.getString("title"));
setLeaf(rs.getInt("isleaf")== 0 ? true : false);
setPdate(rs.getTimestamp("pdate"));
setCont(rs.getString("cont"));
setGrade(0);
}catch(SQLException e){
e.printStackTrace();
}
}
}
我很纠结 ,不知道是哪里的问题,感谢各位给予帮助,谢谢!! --------------------编程问答-------------------- 你的reply.jsp页面里是不是没有页面跳转啊 --------------------编程问答-------------------- --------------------编程问答--------------------
<from action="replyDeal.jsp" method="post">
</from>
这里怎么写成from了?是form
另外,倒底是replyDeal.jsp?还是reply.jsp哩? --------------------编程问答-------------------- <from action="replyDeal.jsp" method="post">
红色地方是不是写错了
应该是action="replyDe.jsp"页面吧 --------------------编程问答--------------------
楼主太粗心,而且出现错误的时候缺乏耐心检查代码 --------------------编程问答-------------------- 谢谢, 楼主说的是, 我还是初学者。我以后一定注意!! --------------------编程问答-------------------- 但是又出现问题了
An error occurred at line: 18 in the jsp file: /replyDeal.jsp
conn cannot be resolved to a variable
15: Connection c = DB.getConn();
16:
17: String sql = "insert into article values (null, ?, ?, ?, ?, now(), ?)";
18: PreparedStatement pstmt = DB.prepareStmt(conn, sql);
19: pstmt.setInt(1, pid);
20: pstmt.setInt(2,rootId);
21: pstmt.setString(3, title);
An error occurred at line: 29 in the jsp file: /replyDeal.jsp
conn cannot be resolved to a variable
26:
27:
28: DB.close(pstmt);
29: DB.close(conn);
30:
31: %>
32:
我还是检查不出来,谢谢各位帮忙检查一下!! --------------------编程问答-------------------- Connection 连接失败,数据库jar包是否导入? --------------------编程问答-------------------- PreparedStatement pstmt = DB.prepareStmt(conn, sql);
改成
PreparedStatement pstmt = DB.prepareStmt(c, sql);
因为你这里定义的变量名是 c : Connection c = DB.getConn(); --------------------编程问答-------------------- 不得行,谢谢了!! --------------------编程问答-------------------- 我的现在已经行了,我什么也没改,就是重写了一遍就行了,我郁闷呀,花了我几个小时的时间!! --------------------编程问答-------------------- 问题解决了吗 --------------------编程问答-------------------- 问题解决了,谢谢!!
补充:Java , Web 开发