java语句注释,解释什么意思,急等着用,谢谢package com.tsinghua.servlet;import java.io.IOException;import java.util.List;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequ
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 05:00:56
java语句注释,解释什么意思,急等着用,谢谢package com.tsinghua.servlet;import java.io.IOException;import java.util.List;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequ
java语句注释,解释什么意思,急等着用,谢谢
package com.tsinghua.servlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.tsinghua.DAO.DAO;
import com.tsinghua.bean.pageBean;
public class search_Servlet extends HttpServlet {
\x09/**
\x09*
\x09*/
\x09public void doGet(HttpServletRequest request, HttpServletResponse response)
\x09\x09\x09throws ServletException, IOException
\x09{
\x09\x09request.setCharacterEncoding("gbk");
\x09\x09response.setCharacterEncoding("text/html;charset=gbk");
\x09\x09String idx = request.getParameter("id");
\x09\x09String name = request.getParameter("name");
\x09\x09String sex = request.getParameter("sex");
\x09\x09String class_ = request.getParameter("class_");
\x09\x09String address = request.getParameter("address");
\x09\x09
\x09\x09String sql = "select * from stu_info where";
\x09\x09String sql1 = "select count(*) from stu_info where";
\x09\x09
\x09\x09if(idx!=null && !idx.equals(""))
\x09\x09{
\x09\x09\x09sql=sql+" idx = " + idx +" and";
\x09\x09\x09sql1=sql1+" idx =" + idx +" and";
\x09\x09}
\x09\x09if(name!=null && !name.equals(""))
\x09\x09{
\x09\x09\x09sql = sql +" nam like '%" + name +"%' and";
\x09\x09\x09sql1 = sql1 +" nam like '%" + name +"%' and";
\x09\x09}
\x09\x09if(sex!=null && !sex.equals(""))
\x09\x09{
\x09\x09\x09sex = new String(sex.getBytes("iso8859-1"));
\x09\x09\x09sql = sql +" sex like '%" + sex +"%' and";
\x09\x09\x09sql1 = sql1 +" sex like '%" + sex +"%' and";
\x09\x09}
\x09\x09if(class_!=null && !class_.equals(""))
\x09\x09{
\x09\x09\x09sql = sql +" class like '%" + class_ +"%' and";
\x09\x09\x09sql1 = sql1 +" class like '%" + class_ +"%' and";
\x09\x09}
\x09\x09if(address!=null && !address.equals(""))
\x09\x09{
\x09\x09\x09sql = sql +" address like '%" + address+"%' and";
\x09\x09\x09sql1 = sql1 +" address like '%" + address+"%' and";
\x09\x09}
\x09\x09sql = sql.substring(0,sql.length()-5); //截掉SQL 语句的后5个字符
\x09\x09sql1 = sql1.substring(0,sql1.length()-5); //截掉SQL1 语句的后5个字符
\x09\x09
\x09\x09DAO dao =new DAO();
\x09\x09pageBean page = new pageBean();
\x09\x09
\x09\x09int totalRows=(int) dao.getTotalRows(sql1) ; //得到总条数
\x09\x09page.setTotalRows(totalRows); //把总条数放到BEAN里面
\x09\x09
\x09\x09System.out.println(sql);
\x09\x09System.out.println(sql1);
\x09\x09System.out.println(totalRows);
\x09\x09
\x09\x09List results = dao.getInfo1(page,sql);
\x09\x09page.setResult(results);
\x09\x09request.setAttribute("pagebean", page);
\x09\x09
\x09\x09request.getRequestDispatcher("/search_view.jsp").forward(request, response);
\x09}
}
java语句注释,解释什么意思,急等着用,谢谢package com.tsinghua.servlet;import java.io.IOException;import java.util.List;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequ
注释是把这段代码注释掉,在页面能显示.但是不编译.
解释就是你对你写的这段代码解释一下(说明一下这是什么功能,变量含义是什么.)