当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Spring mvc : static resources leading to 405 (Method Not Allowed) error

问题描述:

I am trying to link images,css and js in jsp but it is not getting parsed in my html (chrome console output : 405 (Method Not Allowed) )

Project Structure

  • src
  • Web Content

    • resources (three folders for css,jsp,and images are here)
    • WEB-INF

      • config (tiles.xml and dispatcher.xml)
      • JSP (all the jsp files are here)

I have done mapping for those resources in web.xml

<servlet-mapping>

<servlet-name>dispatcher</servlet-name>

<url-pattern>/</url-pattern>

<url-pattern>*.js</url-pattern>

<url-pattern>*.css</url-pattern>

</servlet-mapping>

Here is resource mapping for the resources

<mvc:resources mapping="/resources/**" location="/resources/" />

<mvc:default-servlet-handler />

<mvc:annotation-driven />

<bean id="viewResolver"

class="org.springframework.web.servlet.view.UrlBasedViewResolver">

<property name="viewClass">

<value>

org.springframework.web.servlet.view.tiles2.TilesView

</value>

</property>

</bean>

<bean id="tilesConfigurer"

class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">

<property name="definitions">

<list>

<value>/WEB-INF/config-files/tiles.xml</value>

</list>

</property>

</bean>

JSP Page

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<div id="page-header" class="flag-container">

<div class="row">

<div class="col-xs-2" id="header-logo">

<a href=".">

<img src="<c:url value="/resources/img/logo.png" />" title="logo" />

</a>

</div>

</div>

</div>

分享给朋友:
您可能感兴趣的文章:
随机阅读: