今天完成内容:
开发家庭小账本
1.编写代码
package com.edu.servlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.edu.dao.Userdao;
import com.edu.entity.User;
@WebServlet("/ResearchByName")
public class ResearchByName extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("utf-8");
response.setCharacterEncoding("utf-8");
String name = request.getParameter("username");
Userdao dao = new Userdao();
List<User> lists = dao.ResearchName(name);
if(lists != null && lists.size()!=0) {
System.out.println("查询成功!!!");
request.setAttribute("list", lists);
request.getRequestDispatcher("/Showname.jsp").forward(request, response);
}
else {
System.out.println("查询失败!!!");
request.getRequestDispatcher("/Showname.jsp").forward(request, response);
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
查询代码
遇到问题:
无
明日目标:
学习Android studio的开发