2011-10-27 2 views
1

나는 일식 인디고에서 Jetty 7 임베디드 모드를 설정했다. 내가 부두를 Eclipse에서 시작하면 내 web.xml 및 spring-servlet.xml 구성을로드하지 않는 것 같습니다. 나는 그물을 검색하고, 모두 나와 같은 구성을하고 있지만 내 것이로드되지 않는 것 같습니다. 내가 깜빡 했니? 또는 부두 7 구성은 부두 6과 다릅니다.Jetty 7 스프링 웹 3.0.5를위한 web.xml 설정

Main.java

Server server = new Server(8080); 

    WebAppContext context = new WebAppContext(); 
    context.setResourceBase("../jettyserver/webapp"); 
    context.setContextPath("/"); 
    context.setParentLoaderPriority(true); 

    HandlerList handlers = new HandlerList(); 
    handlers.setHandlers(new Handler[]{ context, new DefaultHandler()}); 

    server.setHandler(context); 
    try { 
     server.start(); 
    server.join(); 
    } catch (Exception e) { 
    e.printStackTrace(); 
    } 

web.xml을

<welcome-file-list> 
    <welcome-file>index.jsp</welcome-file> 
</welcome-file-list> 

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

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

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

<servlet-mapping> 
    <servlet-name>spring</servlet-name> 
    <url-pattern>*.html</url-pattern> 
</servlet-mapping> 

봄-servlet.xml에

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:p="http://www.springframework.org/schema/p" 
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-3.0.xsd"> 

<context:annotation-config /> 
    <context:component-scan base-package="com.jetty.controller" /> 

    <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/jsp/" /> 
     <property name="suffix" value=".jsp" /> 
    </bean> 
</beans> 

답변

0

되지 않음 전문가 여기하지만 당신은 이클립스를 사용하는 경우 내가 말할 것 리소스 기반에 문제가있을 수 있습니다.

여기에서 Eclipse를 사용하는 방법 (WTP, Maven 등)에 따라 컴파일 된 코드가 대상 폴더의 어딘가에 저장됩니다. 그러나 귀하의 JSP와 모두가 따르지 않을 수도 있고 그렇지 않을 수도 있습니다.

코드를 컴파일하고 대상 폴더를 보면 그 위치를 볼 수 있습니다. 비슷한 일을하지만 테스트 코드이므로 경로가 내 IDE에 연결되어 있는지 신경 쓰지 않아도됩니다. 우리의 버전은 다음을 제외하고, 옆으로 거의 동일, 실용적 차이가 있습니다

WebAppContext webapp = new WebAppContext(); 
    webapp.setDescriptor("target/app/WEB-INF/web.xml"); 
    webapp.setResourceBase("target/app"); 
    webapp.setContextPath("/app"); 

이클립스 작업 공간에서 프로젝트의 루트 경로는 내 여기 애플리케이션 런타임의 루트 경로를 볼 수 있듯이. 나는 그것이 프로젝트의 루트 경로에 관련된 물건이라는 것을 알기 위해 광산을 세웠다.

그러나 두 환경에서 실행되는 코드를 찾고 배포 한 경우 특정 응용 프로그램의 실행 구성에서 루트 폴더를 변경하고 직접 대상 (또는 사용자에게 적합한 방식)으로 설정할 수 있습니다. 여기에 더 결정적인없는 죄송합니다

, 어쨌든

이 도움이되기를 바랍니다.