我在做后台里的一个更新数据的功能。
我起始的页面是chanping_detail.jsp,里面有10条数据,是成功连接到数据库里的。然后分别点击这10条链接,打开的页面是chanping_detail.jsp?id="1~10",其中也分别显示了10条数据,我觉得应该就是这么做的吧,到这里都没有问题。
我现在想做的是在显示数据的那个区域做个表单,我对显示的数据进行修改后,因为数据都已经显示在这个表单的区域里了,我就想加个按键“修改”,然后将现在表单里的数据与数据库里的数据进行更新,这么想,应该都是没有问题的吧?
我的表单这样的<form id="form1" name="form1" method="post" action="addpro.jsp">,
addpro.jsp的代码是
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="beans.ProductDetails"%>
<%@ page import="beans.NewsProductBean"%><%
request.setCharacterEncoding("gb2312");
String id=request.getParameter("id");
String title=request.getParameter("title");
String content=request.getParameter("content"); ProductDetails item1=new ProductDetails();
item1.setContent(content);
item1.setID(id);
item1.setTitle(title);

try{
NewsProductBean bean1=new NewsProductBean();
bean1.update(item);
}catch(Exception e){
e.printStackTrace();
}
response.sendRedirect("index2.jsp"); %>
最上面那个类我都编译好了,也放好了文件位置,因为这前我做显示数据库里的数据也做了这样一个<%@ page import="beans.connDB"%>,用来连接数据库的,所以这些JAVA和CLASS文件应该是没有问题的,可是在我点击那个“修改”按键时,报的错误是:
org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 7 in the generated java file
Only a type can be imported. beans.ProductDetails resolves to a packageAn error occurred at line: 8 in the generated java file
Only a type can be imported. beans.NewsProductBean resolves to a packageAn error occurred at line: 11 in the jsp file: /addpro.jsp
ProductDetails cannot be resolved to a type
8:  String title=request.getParameter("title");
9:  String content=request.getParameter("content");
10: 
11:  ProductDetails item1=new ProductDetails();
12:  item1.setContent(content);
13:  item1.setID(id);
14:  item1.setTitle(title);
An error occurred at line: 17 in the jsp file: /addpro.jsp
NewsProductBean cannot be resolved to a type
14:  item1.setTitle(title);
15: 
16:  try{
17:  NewsProductBean bean1=new NewsProductBean();
18:  bean1.update(item);
19:  }catch(Exception e){
20:  e.printStackTrace();
————————————————————————————
不知道各位前辈是否愿意花些时间帮我看看这是什么原因呢?我有些着急了,谢谢!