samedi 10 janvier 2015

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


Vote count:

0




*Good day to you all, friends! Whatever I try, I still get 404 error message, and I truly have no idea what to do.. I was trying to fix it during the 2 days, and still hopeless: When I click on the link on the index.jsp, insted of getting view.jsp page, I get: HTTP Status 404 - /WEB-INF/circle.jsp


IDE: Intellij Idea 13


file structure: You can view my file structure here via this link: http://ift.tt/1B2oV9c


error img: You can vie my error img here via this link: http://ift.tt/1DLzLzY


MainController.java



@Controller
public class MainController {
@Autowired
@Qualifier("rectanglePoint")
private Shape rectanglePoint;

@Autowired
@Qualifier("rectangle")
private Shape rectangle;

@Autowired
@Qualifier("circle")
private Shape circle;


public MainController(){

}
@RequestMapping(value = "/rectanglepoint", method = RequestMethod.GET)
public ModelAndView rectanglePoint(){
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("message", rectanglePoint.square());
modelAndView.setViewName("view");
return modelAndView;
}

@RequestMapping(value = "/rectangle", method = RequestMethod.GET)
public ModelAndView rectangle(){
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("message", rectangle.square());
modelAndView.setViewName("view");
return modelAndView;
}

@RequestMapping(value = "/circle", method = RequestMethod.GET)
public ModelAndView circle(){
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("message", circle.square());
modelAndView.setViewName("view");
return modelAndView;
}
}


springframeworkmvc-servlet.xml :



<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:context="http://ift.tt/GArMu7"
xmlns:mvc="http://ift.tt/1bHqwjR"

xsi:schemaLocation="
http://ift.tt/GArMu6 http://ift.tt/1jdM0fG
http://ift.tt/GArMu7 http://ift.tt/1dfrlFf
http://ift.tt/1bHqwjR http://ift.tt/1DLzLA2">

<context:component-scan base-package="controllers"/>

<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/" />
<property name="suffix" value=".jsp"/>
</bean>

<bean id="rectanglePoint" class="classes.RectanglePoint">
<constructor-arg index="0" ref="pointleft"/>
<constructor-arg index="1" ref="pointright"/>
</bean>
<bean id="circle" class="classes.Circle">
<constructor-arg index="0" value="5"/>
</bean>
<bean id="rectangle" class="classes.Rectangle ">
<constructor-arg index="0" value="2"/>
<constructor-arg index="1" value="5"/>
</bean>

<bean id="pointleft" class="classes.Point">
<constructor-arg name="x" value="1"/>
<constructor-arg name="y" value="2"/>
</bean>
<bean id="pointright" class="classes.Point">
<property name="x" value="2"/>
<property name="y" value="1"/>
</bean>


web.xml



<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://ift.tt/nSRXKP"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/nSRXKP
http://ift.tt/1eWqHMP"
version="3.0">
<display-name>springframework</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/springframeworkmvc-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>springframeworkmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springframeworkmvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>


view.jsp



<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title></title>
</head>
<body>
${message}
</body>
</html>


index.jsp



<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://ift.tt/kTyqzh">
<html>
<head></head>
<body>
<a href="/circle.do">link</a>
</body>
</html>


asked 28 secs ago







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

Aucun commentaire:

Enregistrer un commentaire