2015-01-16 2 views
0

Я снова и снова получаю эту ошибку ...Нет отображения найдено для запроса HTTP с URI [] в DispatcherServlet пока файл не доступен

web.xml

<web-app id="WebApp_ID" version="2.4" 
    xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 
<display-name>brb</display-name> 
<welcome-file-list> 
    <welcome-file>index.jsp</welcome-file> 
</welcome-file-list> 

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

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

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

BRB -servlet.xml

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

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

<mvc:annotation-driven/> 

<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver"> 
    <property name="prefix" value="" /> 
    <property name="suffix" value="" /> 
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> 
</bean> 

<bean name="simple" class="spring.SimpleBean"> 
    <constructor-arg index="0" value="1"/> 
    <constructor-arg index="1" value="1"/> 
</bean> 

класс Controller, как это:

@Controller 
public class BrbController{ 


@RequestMapping(value = "/", method = GET) 
public String index() { 
    System.out.println(this.getClass().getClassLoader().getResource("index.jsp")); // i check is file is available, actually I've coppied it in all resource directories presented 
    return "index.jsp"; 
} 

Я пытаюсь GER это простое приложение, работающее под внедренного Jetty, но по какой-то причине Spring MVC не может видеть файлы представлений.

UPDATE: Я пытаюсь открыть "локальный: 9123 /"

+0

Во время запроса с использованием * what * URI? – Raedwald

+0

Извините. Не навязывал это. Просто localhost: 9123/ –

+0

Вы сопоставили приложение с корнем? Другими словами, «localhost: 9123 /» разрешает ваше веб-приложение? Если это не поможет - http://stackoverflow.com/questions/8219148/how-to-map-a-servlet-filter-on-in-jetty – ramp

ответ

0

Примечание: непроверенная.

Во-первых, попытаться сопоставить ваш <url-pattern> в вашем web.xml:

<servlet-mapping> 
    <servlet-name>brb</servlet-name> 
    <url-pattern>/*</url-pattern> 
</servlet-mapping> 

Если вам нужен контекст-корневой путь, а затем укажите имя контекста на <url-pattern>:

<servlet-mapping> 
    <servlet-name>brb</servlet-name> 
    <url-pattern>/api</url-pattern> 
</servlet-mapping> 

Во-вторых, ваш RequestMapping должно иметь отображение context-path.

@RequestMapping(value = "/start", method = GET) 

Надеюсь, это поможет.

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

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