log: 09:47:07,311 WARN PageNotFound:1110 - No mapping found for HTTP request with URI [/contas/lista] in DispatcherServlet with name 'springmvc'
conectando ...
nao estou conseguindo compreender porque não dispara para views/conta/lista.jsp
veja código
package br.com.caelum.contas.controller;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.ModelAndView;
import br.com.caelum.contas.dao.ContaDAO;
import br.com.caelum.contas.modelo.Conta;
@Controller
public class ContaController {
@RequestMapping("/form")
public String formulario(){
return "formulario";
}
@RequestMapping("/adicionaContaForm")
public String adiciona( Conta conta ){
//System.out.println( "Descricao "+ conta.getDescricao() );
ContaDAO contaDAO = new ContaDAO();
contaDAO.adiciona(conta);
return "conta-adicionada";
}
@RequestMapping("/listaContas")
public ModelAndView lista(){
ContaDAO dao = new ContaDAO();
List<Conta> contas = dao.lista();
System.out.println("Numero de registros:"+contas.size());
ModelAndView mv = new ModelAndView("conta/lista");
mv.addObject("todasContas",contas);
return mv;
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Listagem de Contas</title>
</head>
<body>
<table>
<tr>
<th>Código</th>
<th>Descrição</th>
<th>Valor</th>
<th>Tipo</th>
<th>Pago?</th>
<th>Dt Pagamento</th>
<th>Ações</th>
</tr>
<c:forEach items="${todasContas}" var="conta">
<tr>
<td>${conta.id}</td>
<td>${conta.descricao}</td>
<td>${conta.valor}</td>
<td>${conta.tipo}</td>
<td>
<c:if test="${conta.para eq false }">
NaoPago!
</c:if>
<c:if test="${conta.para eq true }">
Pago!!
</c:if>
</td>
<td>
<fmt:formatDate value="#{conta.dataPagamento.time}" pattern="dd/MM/yyyy"/>
</td>
<td>Açoes</td>
</tr>
</c:forEach>
</table>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="br.com.caelum.contas" />
<mvc:annotation-driven />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="conversionService"
class="org.springframework.context.support.ConversionServiceFactoryBean">
<property name="converters">
<list>
<bean class="br.com.caelum.contas.StringToEnumConverterFactory"/>
</list>
</property>
</bean>
</beans>
<?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">
<display-name>contas</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<!-- Declaracao do servlet do Spring MVC abaixo-->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-context.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>