简体   繁体   English

具有嵌入式Jetty静态资源的Spring MVC

[英]Spring MVC with Embedded Jetty static resources

I am using Embedded Jetty: 我正在使用嵌入式码头:

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

My spring context xml file is: 我的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"/>

When I try to get http://localhost:8080/index.html I get 404 http status code. 当我尝试获取http://localhost:8080/index.html我得到404 http状态代码。

What I am doing wrong? 我做错了什么? Why can't I get the static resource? 为什么我不能获得静态资源?

问题是其他servlet的映射应该是“ /”而不是“ / *”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM