簡體   English   中英

具有嵌入式Jetty靜態資源的Spring MVC

[英]Spring MVC with Embedded Jetty static resources

我正在使用嵌入式碼頭:

 ServletContextHandler context = new ServletContextHandler();
 JettyHttpThreadPool jettyHttpThreadPool = new JettyHttpThreadPool(serviceName);
 server.setHandler(context);
 server.start();

我的spring context xml文件是:

<mvc:annotation-driven>
    <mvc:message-converters>
        <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
            <property name="objectMapper" ref="mapper"/>
        </bean>
    </mvc:message-converters>
</mvc:annotation-driven>

<mvc:resources mapping="css/**" location="classpath:/META-INF/resources/"/>
<mvc:resources mapping="images/**" location="classpath:/META-INF/resources/"/>
<mvc:resources mapping="lib/**" location="classpath:/META-INF/resources/"/>
<mvc:resources mapping="swagger-ui.js" location="classpath:/META-INF/resources/"/>
<mvc:resources mapping="/" location="classpath:/META-INF/resources/"/>

<bean id="mapper" class="com.rest.utils.ObjectMapperFactory"/>

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

當我嘗試獲取http://localhost:8080/index.html我得到404 http狀態代碼。

我做錯了什么? 為什么我不能獲得靜態資源?

問題是其他servlet的映射應該是“ /”而不是“ / *”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM