
高手帮忙!!!解释一段JAVA的程序,要尽量详细!!!
publicclassTypesAddServletextendsHttpServlet{publicTypesAddServlet(){super();publicvo...
public class TypesAddServlet extends HttpServlet {
public TypesAddServlet() {
super();
public void destroy() {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Validate vd = new Validate();
String name = vd.getUnicode(request.getParameter("name"));
String c1 = vd.getUnicode(request.getParameter("c1"));
String c2 = vd.getUnicode(request.getParameter("c2"));
String c3 = vd.getUnicode(request.getParameter("c3"));
String c4 = vd.getUnicode(request.getParameter("c4"));
if(c1 == null || c1.equals("")){
c1= "无";
if(c2 == null || c2.equals("")){
c2= "无";
if(c3 == null || c3.equals("")){
c3= "无";
if(c4 == null || c4.equals("")){
c4= "无";
}
String sql = "insert into types(name,row1,row2,row3,row4) values('"+name+"','"+c1+"','"+c2+"','"+c3+"','"+c4+"')";
String str = "";
InsertUpdateDelBean ib = new InsertUpdateDelBean();
int flag = ib.insertANDupdateANDdel(sql);
if(flag == -1){
str = "/admin/types_add.jsp";
request.setAttribute("error", "1");
}else{
str = "/admin/types_list.jsp";
request.setAttribute("ok", "1");
RequestDispatcher rd = request.getRequestDispatcher(str);
rd.forward(request, response);
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
public void init() throws ServletException {
package servlet.client;
import bean.SelectBean;
import util.Validate;
public class OperationSearchServlet extends HttpServlet {
public OperationSearchServlet() {
super();
public void destroy() {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Validate vd = new Validate();
String title = vd.getUnicode(request.getParameter("title"));
String types = vd.getUnicode(request.getParameter("types"));
String sql = "select * from operation ";
String[] args = {"id","users","title","content","restricts","types","levels","times","kind","affirm","operationlevel"}
SelectBean sb = new SelectBean();
if(title != null && !title.equals("")){
sql += "where title like '%"+title+"%'";
if(types != null && !types.equals("")){
sql += "where types="+types;
ArrayList al = sb.select(sql, args);
request.setAttribute("operations", al);
RequestDispatcher rd = request.getRequestDispatcher("/client/operation_search.jsp");
rd.forward(request, response);
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
public void init() throws ServletException { 展开
public TypesAddServlet() {
super();
public void destroy() {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Validate vd = new Validate();
String name = vd.getUnicode(request.getParameter("name"));
String c1 = vd.getUnicode(request.getParameter("c1"));
String c2 = vd.getUnicode(request.getParameter("c2"));
String c3 = vd.getUnicode(request.getParameter("c3"));
String c4 = vd.getUnicode(request.getParameter("c4"));
if(c1 == null || c1.equals("")){
c1= "无";
if(c2 == null || c2.equals("")){
c2= "无";
if(c3 == null || c3.equals("")){
c3= "无";
if(c4 == null || c4.equals("")){
c4= "无";
}
String sql = "insert into types(name,row1,row2,row3,row4) values('"+name+"','"+c1+"','"+c2+"','"+c3+"','"+c4+"')";
String str = "";
InsertUpdateDelBean ib = new InsertUpdateDelBean();
int flag = ib.insertANDupdateANDdel(sql);
if(flag == -1){
str = "/admin/types_add.jsp";
request.setAttribute("error", "1");
}else{
str = "/admin/types_list.jsp";
request.setAttribute("ok", "1");
RequestDispatcher rd = request.getRequestDispatcher(str);
rd.forward(request, response);
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
public void init() throws ServletException {
package servlet.client;
import bean.SelectBean;
import util.Validate;
public class OperationSearchServlet extends HttpServlet {
public OperationSearchServlet() {
super();
public void destroy() {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Validate vd = new Validate();
String title = vd.getUnicode(request.getParameter("title"));
String types = vd.getUnicode(request.getParameter("types"));
String sql = "select * from operation ";
String[] args = {"id","users","title","content","restricts","types","levels","times","kind","affirm","operationlevel"}
SelectBean sb = new SelectBean();
if(title != null && !title.equals("")){
sql += "where title like '%"+title+"%'";
if(types != null && !types.equals("")){
sql += "where types="+types;
ArrayList al = sb.select(sql, args);
request.setAttribute("operations", al);
RequestDispatcher rd = request.getRequestDispatcher("/client/operation_search.jsp");
rd.forward(request, response);
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
public void init() throws ServletException { 展开
4个回答
展开全部
是写的一个servlet吧,如果不知道的话,最好自己先去了解一下什么是servlet
public class TypesAddServlet extends HttpServlet {
//构造函数
public TypesAddServlet() {
//父类构造函数
super();
//销毁
public void destroy() {
//取得request,response//了解一下servlet就会知道的
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//Validate这个类没有用过,可以查一下JDK,好像也是自定义的吧
Validate vd = new Validate();
//从request取值,比如取得字段为name对应的值
String name = vd.getUnicode(request.getParameter("name"));
String c1 = vd.getUnicode(request.getParameter("c1"));
String c2 = vd.getUnicode(request.getParameter("c2"));
String c3 = vd.getUnicode(request.getParameter("c3"));
String c4 = vd.getUnicode(request.getParameter("c4"));
//判断这些值
if(c1 == null || c1.equals("")){
c1= "无";
if(c2 == null || c2.equals("")){
c2= "无";
if(c3 == null || c3.equals("")){
c3= "无";
if(c4 == null || c4.equals("")){
c4= "无";
}
//SQL语句,这个应该知道吧
String sql = "insert into types(name,row1,row2,row3,row4) values('"+name+"','"+c1+"','"+c2+"','"+c3+"','"+c4+"')";
String str = "";
//InsertUpdateDelBean类没有用过,应该是在什么地方定义的吧
InsertUpdateDelBean ib = new InsertUpdateDelBean();
//应该是判断是否插入之类的,要根据那些类的定义看
int flag = ib.insertANDupdateANDdel(sql);
if(flag == -1){
str = "/admin/types_add.jsp";
//对request设置值,将“1”设置到error字段中
request.setAttribute("error", "1");
}else{
str = "/admin/types_list.jsp";
//设值
request.setAttribute("ok", "1");
//这点不知道
RequestDispatcher rd = request.getRequestDispatcher(str);
//跳转页面
rd.forward(request, response);
//servlet的方法doPost
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
//初始化servlet
public void init() throws ServletException {
//?????
没完??
//??
//下面同理,如果还是不清楚就没有办法了
package servlet.client;
import bean.SelectBean;
import util.Validate;
public class OperationSearchServlet extends HttpServlet {
public OperationSearchServlet() {
super();
public void destroy() {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Validate vd = new Validate();
String title = vd.getUnicode(request.getParameter("title"));
String types = vd.getUnicode(request.getParameter("types"));
String sql = "select * from operation ";
String[] args = {"id","users","title","content","restricts","types","levels","times","kind","affirm","operationlevel"}
SelectBean sb = new SelectBean();
if(title != null && !title.equals("")){
sql += "where title like '%"+title+"%'";
if(types != null && !types.equals("")){
sql += "where types="+types;
ArrayList al = sb.select(sql, args);
request.setAttribute("operations", al);
RequestDispatcher rd = request.getRequestDispatcher("/client/operation_search.jsp");
rd.forward(request, response);
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
public void init() throws ServletException {
学一下什么是servlet就知道这些了
public class TypesAddServlet extends HttpServlet {
//构造函数
public TypesAddServlet() {
//父类构造函数
super();
//销毁
public void destroy() {
//取得request,response//了解一下servlet就会知道的
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//Validate这个类没有用过,可以查一下JDK,好像也是自定义的吧
Validate vd = new Validate();
//从request取值,比如取得字段为name对应的值
String name = vd.getUnicode(request.getParameter("name"));
String c1 = vd.getUnicode(request.getParameter("c1"));
String c2 = vd.getUnicode(request.getParameter("c2"));
String c3 = vd.getUnicode(request.getParameter("c3"));
String c4 = vd.getUnicode(request.getParameter("c4"));
//判断这些值
if(c1 == null || c1.equals("")){
c1= "无";
if(c2 == null || c2.equals("")){
c2= "无";
if(c3 == null || c3.equals("")){
c3= "无";
if(c4 == null || c4.equals("")){
c4= "无";
}
//SQL语句,这个应该知道吧
String sql = "insert into types(name,row1,row2,row3,row4) values('"+name+"','"+c1+"','"+c2+"','"+c3+"','"+c4+"')";
String str = "";
//InsertUpdateDelBean类没有用过,应该是在什么地方定义的吧
InsertUpdateDelBean ib = new InsertUpdateDelBean();
//应该是判断是否插入之类的,要根据那些类的定义看
int flag = ib.insertANDupdateANDdel(sql);
if(flag == -1){
str = "/admin/types_add.jsp";
//对request设置值,将“1”设置到error字段中
request.setAttribute("error", "1");
}else{
str = "/admin/types_list.jsp";
//设值
request.setAttribute("ok", "1");
//这点不知道
RequestDispatcher rd = request.getRequestDispatcher(str);
//跳转页面
rd.forward(request, response);
//servlet的方法doPost
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
//初始化servlet
public void init() throws ServletException {
//?????
没完??
//??
//下面同理,如果还是不清楚就没有办法了
package servlet.client;
import bean.SelectBean;
import util.Validate;
public class OperationSearchServlet extends HttpServlet {
public OperationSearchServlet() {
super();
public void destroy() {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Validate vd = new Validate();
String title = vd.getUnicode(request.getParameter("title"));
String types = vd.getUnicode(request.getParameter("types"));
String sql = "select * from operation ";
String[] args = {"id","users","title","content","restricts","types","levels","times","kind","affirm","operationlevel"}
SelectBean sb = new SelectBean();
if(title != null && !title.equals("")){
sql += "where title like '%"+title+"%'";
if(types != null && !types.equals("")){
sql += "where types="+types;
ArrayList al = sb.select(sql, args);
request.setAttribute("operations", al);
RequestDispatcher rd = request.getRequestDispatcher("/client/operation_search.jsp");
rd.forward(request, response);
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
public void init() throws ServletException {
学一下什么是servlet就知道这些了
展开全部
是啊,就是一个简单的servlet。先学一下,再看就简单多了 !
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不就是一servlet?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
牛比。。。
这都能解释。哈哈。。。
这都能解释。哈哈。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询