日期:2014-05-17 浏览次数:20922 次
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>selectemp</servlet-name>
<servlet-class>impl.servlet.SelectEmpServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>selectemp</servlet-name>
<url-pattern>/selectemp.do</url-pattern>
</servlet-mapping>
</web-app>
package impl.servlet;
import impl.EmpDaoImpl;
import java.io.IOException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import dto.Emp;
/**
* Servlet implementation class tests
*/
public class SelectEmpServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public SelectEmpServlet() {
System.out.println("进入servlet方法!!!");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try{
List<Emp> list = null;
EmpDaoImpl empimpl = new EmpDaoImpl();
list = empimpl.getEmpList();//获取emp对象集合
if(list.size()>0)
{
request.setAttribute("emplist", list);//查询对象集合放入request作用域
//页面跳转
RequestDispatcher dispatcher = request.getRequestDispatcher("/success.jsp");
dispatcher