高手帮忙!!!解释一段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 {
展开
 我来答
angelicdemon
2008-07-02
知道答主
回答量:58
采纳率:0%
帮助的人:0
展开全部
是写的一个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就知道这些了
乌微月2S
2008-07-02 · TA获得超过5037个赞
知道大有可为答主
回答量:5361
采纳率:42%
帮助的人:3153万
展开全部
是啊,就是一个简单的servlet。先学一下,再看就简单多了 !
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
xiongcan530
2008-07-15 · TA获得超过859个赞
知道小有建树答主
回答量:934
采纳率:0%
帮助的人:680万
展开全部
不就是一servlet?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
青岛耳穴堂
2008-07-15 · 超过28用户采纳过TA的回答
知道答主
回答量:244
采纳率:0%
帮助的人:116万
展开全部
牛比。。。
这都能解释。哈哈。。。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 2条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式