У меня проблемы с отображением значений модели из моего контроллера в моем представлении JSP. Все работает в Tomcat 6. Но это не работает в Tomcat 5.5. Вот мои файлы.
web.xml для Tomcat 5.5 (для Tomcat 6 я использую версию = "2.5" и правильную схему)
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
Версии:
Tomcat : 5,5
Taglib : jstl.jar, standard.jar (версия 1.1)
Контроллер
@Controller
@RequestMapping("/inventory")
public class SimpleController {
@Autowired
@Qualifier("inventoryService")
private IInventoryService inventoryService;
// Our default method when a simple GET request is made to /simple
@SuppressWarnings("unchecked")
@RequestMapping(method = RequestMethod.GET)
public String viewProducts(ModelMap model) {
List<IInventory> retrieved = inventoryService.getInventories();
List <InventoryDTO> inventories = new ArrayList();
for (IInventory inventory: retrieved) {
InventoryDTO inventoryDTO= new InventoryDTO();
inventoryDTO.setId(inventory.getId());
inventoryDTO.setBrandName(inventory.getBrand().getName());
inventories.add(inventoryDTO);
}
model.put ( "inventories", inventories );
// This will resolve to a logical view name /WEB-INF/jsp/inventoriesView.jsp
return "inventoriesView";
}
}
inventoriesView.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<html>
<head>
<style type="text/css">
<%@include file="../../resources/style.css" %>
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Inventories</title>
</head>
<body>
<h1>Inventory</h1>
<br/>
<%@include file="menu.jsp" %>
<br /><br />
<c:if test="${!empty inventories}" >
<table class="table" border="1">
<tr>
<th>ID</th>
<th>Brand</th>
</tr>
<c:forEach items="${inventories}" var="inventory">
<tr>
<td><c:out value="${inventory.id}" /></td>
<td><c:out value="${inventory.brandName}" /></td>
</tr>
</c:forEach>
</table>
</c:if>
<c:if test="${empty inventories}">
There are currently no inventories.
</c:if>
</body>
</html>
Помните, что это работает безупречно в Tomcat 6.0, но не в Tomcat 5.5. Я не получаю никакой ошибки. Это просто не будет отображать данные, как если бы модель была нулевой. Когда я вызываю выражение EL {2 + 2}, я получаю 4 в качестве значения для Tomcat 5.5 и 6. Спасибо