當我想在我的網站訪問,我有以下錯誤:春 - JSTL - 錯誤404 - 請求的資源不可用
The requested resource is not available.
我注意到這個問題是在MVC-調度 - 行<mvc:resources mapping="/resources/**" location="../../resources/normalMode/"/>
-servlet.xml文件,但我不知道爲什麼?
你有什麼解決方案嗎?
我的項目結構:
- src
- main
- java
- com
- myblog
- controller
-//all java files as controller
- resources
- normalMode
- css
- header.css
- webapp
- /WEB-INF
- /pages
- mvc-dispatcher.xml
- web.xml
MVC-調度-servlet.xml中
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.myblog.controller" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property value="org.springframework.web.servlet.view.JstlView"
name="viewClass" />
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<mvc:resources mapping="/resources/**" location="../../resources/normalMode/"/>
</beans>
的web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
IndexController.java
package com.myblog.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping(value={"","/","home"})
public class IndexController {
@RequestMapping(method=RequestMethod.GET)
public ModelAndView init(){
return new ModelAndView("index");
}
}
對於那些要求你得到這個錯誤?什麼網址? –
http:// localhost:8080/lbagno/ – user2274060
lbagno是您的上下文路徑嗎?我們來看看你的web.xml。 –