0

我正在使用嵌入式码头:

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

我的弹簧上下文 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 状态码。

我做错了什么?为什么我无法获取静态资源?

4

1 回答 1

0

问题是另一个 servlet 的映射应该是“/”而不是“/*”

于 2014-11-17T14:12:08.723 回答