lundi 23 février 2015

404 error for Spring MVC Rest URI

I am making a dummy hello world applicatiion for Spring MVC, i have done exactly same as was mentioned in example, but when i run the URL, its giving me the 404 error. Please help me if you can, following are my files:-



web.xml

<web-app id="WebApp_ID" version="2.4"
xmlns="http://ift.tt/qzwahU"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/qzwahU
http://ift.tt/16hRdKA">

<display-name>Spring MVC Application</display-name>
<mvc:default-servlet-handler default-servlet-name="moqahServices"/>
<servlet>
<servlet-name>moqahServices</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

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

<error-page>
<error-code>404</error-code>
<location>/WEB-INF/jsp/error.jsp</location>
</error-page>

</web-app>


moqahServices.xml

<beans xmlns="http://ift.tt/GArMu6"
xmlns:context="http://ift.tt/GArMu7"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="
http://ift.tt/GArMu6
http://ift.tt/QEDs1e
http://ift.tt/GArMu7
http://ift.tt/QEDs1k">

<context:component-scan base-package="com.moqah" />

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>

</beans>

HelloController.jsp

package com.moqah;

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

@Controller
@RequestMapping("/hello")
public class HelloController{
@RequestMapping(method = RequestMethod.GET)
public String printHello(ModelMap model) {
model.addAttribute("message", "Hello Spring MVC Framework!");
return "hello";
}
}



Please let me know if you have any suggestions

Aucun commentaire:

Enregistrer un commentaire