}
EmployeeManagerImpl.java<pre>import java.util.List;</pre>import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import com.howtodoinjava.demo.dao.EmployeeDAO;import com.howtodoinjava.demo.model.EmployeeVO;@Servicepublic class EmployeeManagerImpl implements EmployeeManager { @Autowired EmployeeDAO dao; public List<EmployeeVO> getAllEmployees() { return dao.getAllEmployees(); }}employeesListDisplay.jsp这个jsp被用于显示系统中的所有员工 。它循环遍历employee集合,并且在一个表中打印他们的详细信息 。这符合MVC模式的视图层 。
<pre><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%></pre><html><head><title>Spring MVC Hello World</title></head><body><h2>All Employees in System</h2><table border="1"><tr><th>Employee Id</th><th>First Name</th><th>Last Name</th></tr><c:forEach items="${employees}" var="employee"><tr><td>${employee.id}</td><td>${employee.firstName}</td><td>${employee.lastName}</td></tr></c:forEach></table></body></html>现在在您的应用程序服务器(我用的是Tomcat 7)部署应用程序 。并点击“http://localhost:8080/springmvcexample/employee-module/getAllEmployees” 。如果你已正确配置所有内容,你将会在屏幕下看到:

文章插图
推荐阅读
- Spring框架中的国际化支持
- Spring 常犯的十大错误,这坑你踩过吗?
- 小程序页面栈详解
- Redis并发竞争key的解决方案详解
- 现在程序员最火的微服务架构与SpringCloud,你真的弄清楚了吗?
- Nginx配置文件nginx.conf详解
- 加拿大|加拿大移民详解:如何通过找工作的方式拿到枫叶卡?
- 全套茶具的使用方法详解
- 八卦风水罗盘最详解读
- 十年架构师告诉你到底什么是Spring Boot?
