求救:servlet制作新闻发布系统在后台添加二级分类出错,错误报在public!谢谢高手

flybirdlc 2006-07-16 03:16:56
想制作一个新闻发布系统,有2级分类,在添加二级分类的的页面出现问题,错误报在public,小弟新手,不明白怎么解决
添加二级分类的时候 其上级分类采用下拉列表,使用记录集从数据库获取后while循环加入
sql数据库中一级分类的记录表为 FirstTitle,其中储存1级类别的字段为TitleName
请高手帮助

package news;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;

public class SecondTitleServlet
extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GBK";

//Initialize global variables
public void init() throws ServletException {
}

//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws //错误报在本行的 public
ServletException, IOException, SQLException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();

Connection conn1;
Statement stmt1;
ResultSet rsa;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn1 = DriverManager.getConnection("jdbc:odbc:news");
stmt1 = conn1.createStatement();
rsa = stmt1.executeQuery("select TitleName from FirstTitle");

out.println("<html>");
out.println("<head><title>SecondTitleServlet</title></head>");
out.println("<body bgcolor=\"#ffffff\">");
out.print("<from action='secondtitledbservlet' method='post'>");
out.println("<center><br><h2>二级标题管理</h2><br><br>");
out.println("一级标题:");
out.println("<select name=\"select\" size=\"1\"> ");
while (rsa.next()) { //循环写入下拉菜单,选择1级标题
out.println("<option value=\"" + rsa.getString(0) + "\">" +
rsa.getString(0) + "</option>");
}
out.println("</select>");
out.print("二级标题:<input type='text' name='SecondTitleName'>");
out.print("新闻内容:<input type='textarea' name='NewsBody' cols=25 rows=5>");
out.print("<input typy='submit' values='提交'>");
out.print("</form>");
out.println("</body>");
out.println("</html>");
out.close();
}
catch (Exception e) {
e.toString();
}

}

//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException, SQLException {
doGet(request, response);
}

//Clean up resources
public void destroy() {
}
}
...全文
115 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
flybirdlc 2006-07-16
  • 打赏
  • 举报
回复
去掉还是有错啊
喝酒吃肉 2006-07-16
  • 打赏
  • 举报
回复
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException, SQLException {
这行去掉SQLException
flybirdlc 2006-07-16
  • 打赏
  • 举报
回复
还是有错,不过错误变成下面的了

doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) in news.SecondTitleServlet cannot override doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) in javax.servlet.http.HttpServlet; overridden method does not throw java.sql.SQLException:18:3
Unable to design SecondTitleServlet.java. Make sure that the file is in the current project, does not contain any syntax errors, and that all resources are compiled.
everyluck 2006-07-16
  • 打赏
  • 举报
回复
不可以有SQLException这个异常抛出,你应该换成try catch形式的.
flybirdlc 2006-07-16
  • 打赏
  • 举报
回复
doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) in news.SecondTitleServlet cannot override doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) in javax.servlet.http.HttpServlet; overridden method does not throw java.sql.SQLException:18:3
Unable to design SecondTitleServlet.java. Make sure that the file is in the current project, does not contain any syntax errors, and that all resources are compiled.

以上是错误信息

81,094

社区成员

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

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