lovelyim92
lovelyim92

Reputation: 161

404 error on Spring hello world program

I was creating a basic Hello World program. Everything I coded appears to be correct, but the program is not working.

Servlet web.xml is :

<servlet>
    <servlet-name>MyDispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>MyDispatcher</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

Dispatcher Servlet is :

<context:component-scan base-package="com.controller" />
    <bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/JSP/" />
    <property name="suffix" value=".jsp" />
    </bean>

calling callingDate.html :

<body>
    <p>
        <a href="showdate.html">click here to get DATE TIME.</a>
    </p>
</body>

called showing.jsp :

<body>
    today date time string is :
    <span>${date}</span>
</body>

controller class :

package com.controller;

import java.util.Date;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/showdate")
public class DateShowController {
    @RequestMapping(method = RequestMethod.GET)
    public String showmethod(ModelMap model) {
        model.addAttribute("date", new Date());
        return "showing";
    }
}

Class hierarchy is: Class hierarchy

Upvotes: 0

Views: 107

Answers (1)

maximede
maximede

Reputation: 1823

Try removing the .html in <a href="showdate.html">

Upvotes: 1

Related Questions