Olá pessoal do fórum.
Estou escrevendo pois não tenho mais o que fazer a respeito de um problema que ocorre comigo utilizando o Spring 2.5 e Annotations.
Já li a apostila mais recente da caelum umas 20 vezes e não consigo entender porque toda vez que chamo uma ação por exemplo aparece a página de erro 404 do html informando que o arquivo não foi encontrado.
Meu web.xml está assim:
[code]
<?xml version="1.0" encoding="UTF-8"?> contextConfigLocation /WEB-INF/applicationContext.xml org.springframework.web.context.ContextLoaderListener Servlet dispatcher 2.0 org.springframework.web.servlet.DispatcherServlet <load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Servlet dispatcher 2.0</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>redirect.jsp</welcome-file>
</welcome-file-list>
[/code]
Já o arquivo “Servlet dispatcher 2.0-servlet.xml” que é o arquivo de configuração do spring está assim.
<?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:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.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">
<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
<!--
Most controllers will use the ControllerClassNameHandlerMapping above, but
for the index controller we are using ParameterizableViewController, so we must
define an explicit mapping for it.
-->
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="index.htm">indexController</prop>
</props>
</property>
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />
<!--
The index controller.
-->
<bean name="indexController"
class="org.springframework.web.servlet.mvc.ParameterizableViewController"
p:viewName="index" />
<context:component-scan base-package="bs"/>
</beans>
E tenho a classe:
@Controller
public class TesteController {
@RequestMapping(value="/teste")
public String adicionaPlanoConta(){
return "ok";
}
}
e o resultado de tudo isso é sempre que tento usar o link <a href="teste">Clique aqui para testar</a>
ou até um form que criei com um botão submit:
[code]
[/code]Resultam no erro 404.
Se alguem puder me ajudar ficarei muito grato.