一个论坛程序是用jsp+servletjavabean模式的
程序里面的所有的servlet类都出现了啊警告不知什么原因例如
一个LoginServlet就出现警告提示为:
add default serial version ID
add generated serial version ID
rename in file
源码如下:
package com.wxpn.tutorial.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.wxpn.tutorial.db.ConnectionPool;
import com.wxpn.tutorial.db.DB;
/**
* Servlet implementation class for Servlet: LoginServlet
*/
public class LoginServlet extends javax.servlet.http.HttpServlet implements
javax.servlet.Servlet {
public LoginServlet() {
super();
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
String result = "";
// 获取提交的用户名:
String strUserName = request.getParameter("txtUserName");
// 获取提交的密码:
String strPassword = request.getParameter("txtPassword");
// 创建数据库连接对象:
ConnectionPool connPool = DB.getConnPool();
Connection conn = connPool.getConnection();
Statement stmt = null;
ResultSet rs = null;
try {
// sql语句:
String sql = "select * from userinfo where username='"
+ strUserName + "' and userpwd='" + strPassword + "'";
// 创建数据记录集对象:
stmt = conn.createStatement();
// 执行sql语句,返回一个记录集到rs:
rs = stmt.executeQuery(sql);
// 如果记录集为非空,表明有相匹配的用户名和密码,登录成功:
if (rs.next()) {
// 登录成功时,把strUserName设成session变量UserName
request.getSession(true).setAttribute("userName", strUserName);
response.sendRedirect("index.jsp");
} else {
// 否则(记录集为空),表明失败:
request.setAttribute("error", "登录失败");
try {
request.getRequestDispatcher("/error.jsp").forward(request,
response);
} catch (Throwable t) {
getServletContext().log(t.getMessage());
}
}
} catch (SQLException sqlExc) {
sqlExc.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
// 关闭连接,释放数据库资源:
try {
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
connPool.freeConnection(conn);
} catch (SQLException sqlExc) {
sqlExc.printStackTrace();
}
}
}
}
这个问题该怎么解决啊??本人刚开始学java问题很多,还请大家多多帮助我啊~