Я пробовал следовать руководству, чтобы изучить Spring. Я использовал Netbeans, и похоже, что Spring не «видит» контроллер, но я не вижу никаких значимых ошибок в журналах Apache.
Всякий раз, когда я нажимаю кнопку отправки формы, я получаю ошибку 404. Я искал в Интернете даже здесь. Хотелось бы разобраться в ошибке, а не просто что-то скопировать и вставить.
<html>
<body>
<h2>Hello World!</h2>
<form action = "add">
<input type = "text" name = "t1"><br />
<input type = "text" name = "t2"><br />
<input type = "submit">
</form>
</body>
</html>
<?xml version = "1.0" encoding = "windows-1252"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<beans xmlns = "http://www.springframework.org/schema/beans"
xmlns:ctx = "http://www.springframework.org/schema/context"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc = "http://www.springframework.org/schema/mvc"
xsi:schemaLocation = "http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd ">
<ctx:annotation-config></ctx:annotation-config>
<ctx:component-scan base-package = "com.ffuentese"></ctx:component-scan>
<bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name = "prefix">
<value>/WEB-INF/</value>
</property>
<property name = "suffix">
<value>.jsp</value>
</property>
</bean>
<mvc:annotation-driven/>
</beans>
package com.ffuentese;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Francisco
*/
@Controller
public class AddController
{
@RequestMapping("/add")
public String add(){
return "display.jsp";
}
}
<?xml version = "1.0" encoding = "UTF-8"?>
<web-app xmlns = "http://java.sun.com/xml/ns/javaee"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version = "3.0">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<servlet>
<servlet-name>ffuentese</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ffuentese</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
</web-app>
Как я сказал выше, этого не было. Ответ был уже предоставлен VHS.




Ваша конфигурация в web.xml неверна.
Измените шаблон URL с «.htm "в" /». Таким образом, каждый запрос, поступающий на ваш сервер приложений, будет перенаправлен сервлету диспетчера Spring.
Поделитесь, пожалуйста, ошибкой.