我有mvc:resources
servlet映射問題wtih MVC資源春
我main-servlet.xml
**
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="50000000" />
</bean>
<mvc:resources mapping="/images/**" location="/images/" />
<mvc:resources mapping="/css/**" location="/css/" />
**
一個問題,當我發表意見mvc:resources
行的一切(否則)奇蹟般地開始工作。但是當我取消註釋時,只有這些資源纔有效。編譯時,日誌說只有css/**和images/**被映射,並且沒有其他映射。
web.xml文件:
<servlet-mapping>
<servlet-name>main</servlet-name>
<url-pattern>/css/**</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>main</servlet-name>
<url-pattern>/images/**</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>main</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
我試圖把2周調度的servlet但這並不工作要麼。另一個servlet被讀取並且被映射,但請求默認爲主servlet。
編譯日誌後從web.xml中評論/ CSS/**和/圖片/ **:
**
org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/images/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
Nov 26, 2013 11:40:40 AM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/css/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#1'
Nov 26, 2013 11:40:40 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'resources': initialization completed in 220 ms
Nov 26, 2013 11:40:40 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'main'
Nov 26, 2013 11:40:40 AM org.springframework.web.servlet.FrameworkServlet initServletBean
**
INFO: FrameworkServlet 'main': initialization completed in 234 ms
Nov 26, 2013 11:40:40 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Nov 26, 2013 11:40:40 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Nov 26, 2013 11:40:53 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/KT/] in DispatcherServlet with name 'main'
剛剛嘗試過。不工作:(現在編譯日誌 –
請注意,你不應該把它稱爲_compilation_,它不是編譯,它是啓動/引導日誌, –
什麼是_everything(else)_開始工作? –