2015-04-06 2 views
0

Im в середине проекта SpringMVC, и я столкнулся с ошибкой «отсутствие отображения».ПРЕДУПРЕЖДЕНИЕ. Не найдено сопоставления для HTTP-запроса с URI [/ EventZone/register /] в DispatcherServlet с именем 'dispatcher'

Вот мой web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> 


    <display-name>Archetype Created Web Application</display-name> 

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

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

    <context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value>/WEB-INF/dispatcher-servlet.xml</param-value> 
    </context-param> 

    <listener> 
     <listener-class> 
      org.springframework.web.context.ContextLoaderListener 
     </listener-class> 
    </listener> 
</web-app> 

диспетчеру-servlet.xml:

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation=" 
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
http://www.springframework.org/schema/mvc 
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.1.xsd"> 


    <mvc:resources mapping="/resources/**" location="/resources/" /> 

    <mvc:annotation-driven /> 

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


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

класс контроллера:

package controller; 

import org.springframework.stereotype.Controller; 
import org.springframework.web.bind.annotation.RequestMapping; 
import org.springframework.web.bind.annotation.RequestMethod; 
import org.springframework.web.servlet.ModelAndView; 

@Controller 
@RequestMapping("/EventZone/register/") 
public class LoginController { 

    @RequestMapping(method = RequestMethod.GET) 
    public ModelAndView getRegisterPage(){ 

     ModelAndView model = new ModelAndView("RegisterViews/register"); 


     return model; 
    } 
} 

Im пытаясь каждое решение, которое я могу найти, но ни один не кажется работать.

+0

Каков полный URL-адрес, который вы пытаетесь удалить? Также включите ваш веб-текст. – minion

+0

URL-адрес: http: // localhost: 8040/EventZone/register/ Что вы подразумеваете под «include webcontext»? – lvi

+0

Обычно вы ударяете URL-адрес шаблона 'localhost: 8040/{webcontext}/EventZone/register'. Я вижу, что вам не хватает вебконтекста. Каков ваш веб-контекст? – minion

ответ

0

yes i.e то, чего вам не хватало, нет необходимости в дополнительной логике, которую нужно добавить wecontext, означает ваше имя приложения. http://localhost:8080/SpringMVN/EventZone/register/ расскажите, как вы развертываете свое приложение. и, наконец, добавьте '/', который вам не хватает, потому что вы указали по запросу в своем классе контроллера.

Смежные вопросы

 Смежные вопросы