HTTP Server Status 404 Error in Spring MVC Project

Aj Styles :

I am following the same tutuorial as in this 404 Error - Java Spring MVC using Maven in Eclipse from Tutorial and after filling the form i am getting 404 Error

index.jsp

<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <form action="add">
    <input type="text" name="t1"><br>
    <input type="text" name="t2"><br>
    <input type="submit">   
    </form>
</body>
</html>

web.xml

    <!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
  <display-name>Archetype Created Web Application</display-name>
  
  <servlet>          
    <servlet-name>telusko</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    
  </servlet>
 
  <servlet-mapping>
    <servlet-name>telusko</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

AddController.java

package com.telusko;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class AddController {
    @RequestMapping("/add")
    public String add() {
        return "display.jsp";
    }
}

telusko-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<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.telusko"></ctx:component-scan>
</beans>

display.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Hello World
</body>
</html>

Source Project

enter image description here

So how can i succesfully get the "display.jsp" page after filling the form.

Aj Styles :

It Helps Me

I have just created few changes and i succesfully remove the HTTP 404 Error even after adding RequestMapping Annotation

I have just move my packageand classes into the src/main/java and not into the src/main/resources which i have to created manually, and that should resolve the Mapping error.

New Project Structure

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to fix "HTTP Status 404" Spring MVC

Spring MVC. HTTP Status 404

First application in Spring MVC - HTTP Status 404

Can someone explain this error for me 'HTTP Status 404 – Not Found Spring MVC'?

Why when I submit a form into a Spring MVC application I obtain this HTTP Status 404 error page?

Redirection error in spring MVC (http status 404 the requested resource is not available jsp )

Spring Mvc get HTTP Status [404] – [Not Found] after the submission

Spring Mvc App get - HTTP Status [404] – [Not Found]

HTTP status 404 error running TimeForm servlet project in NetBeans

After Spring Security authentication get HTTP Status 404 error

Spring MVC 404 error

spring-mvc-404 page not found error in maven project

Spring MVC return custom HTTP status code (no error)

Embedded Jetty - Spring MVC - view resolver - NO XML - HTTP ERROR: 404

Server error in application '/'. HTTP 404. MVC ASP.NET

Maven web project HTTP Status [404] – [Not Found]

HTTP Status 500 in spring MVC

Spring 5 - HTTP Status 500 – Internal Server Error

Spring MVC @Autowired and @ModelAttribute HTTP Status 404 - /WEB-INF/circle.jsp

Spring Security Login Error : HTTP Status 404 - /j_spring_security_check

HTTP Status 404 – Not Found Spring Boot

HTTP Status 404 – Not Found tomcat spring

HTTP Status [404] ? [Not Found] for /login in spring security

HTTP Status 404 – Not Found on Tomcat server

Why do I always get Whitelabel Error Page with status “404” while running Spring Boot Project

Failed to load resource: the server responded with a status of 404 error after deploying project

I am getting a 'Failed to load resource: the server responded with a status of 404 ()' error for my audio files in my project

Node express 404 error HTTP status code

Eclipse & Tomcat Error: HTTP Status 404 – Not Found: