Note that there are some explanatory texts on larger screens.

plurals
  1. PO405 Error Getting Resources
    text
    copied!<p>I have a Spring MVC application in which I am getting a 405 error whenever I request resources.</p> <p>I have the following in my servlet.xml file:</p> <pre><code>&lt;context:component-scan base-package="com.xetius"/&gt; &lt;mvc:annotation-driven/&gt; &lt;mvc:resources mapping="/images/**" location="classpath:/images/"/&gt; &lt;mvc:resources mapping="/thumbs/**" location="classpath:/thumbs/"/&gt; &lt;mvc:resources mapping="/gallery/**" location="classpath:/gallery/"/&gt; &lt;mvc:resources mapping="/style/**" location="classpath:/style/"/&gt; &lt;mvc:resources mapping="/script/**" location="classpath:/script/"/&gt; &lt;mvc:resources mapping="/downloads/**" location="classpath:/downloads/"/&gt; &lt;bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" /&gt; &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt; &lt;property name="viewClass"&gt; &lt;value&gt;org.springframework.web.servlet.view.tiles2.TilesView&lt;/value&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"&gt; &lt;property name="definitions"&gt; &lt;list&gt; &lt;value&gt;/WEB-INF/views/**/views.xml&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre> <p>and in my home.jsp file I have the following:</p> <pre><code>&lt;img class="about" src="/images/about.jpg" alt="about" /&gt; </code></pre> <p>When I run this inside IntelliJ using Tomcat7 all resources are being returned as 405 Method Not Allowed. Below is the HAR for that request</p> <pre><code>{ "startedDateTime": "2012-11-27T08:38:32.453Z", "time": 8, "request": { "method": "GET", "url": "http://localhost:8080/images/about.jpg", "httpVersion": "HTTP/1.1", "headers": [ { "name": "Accept-Encoding", "value": "gzip,deflate,sdch" }, { "name": "Accept-Language", "value": "en-GB,en-US;q=0.8,en;q=0.6" }, { "name": "Cookie", "value": "JSESSIONID=0A0475B4404B037CD2FDD8876A02285A" }, { "name": "Connection", "value": "keep-alive" }, { "name": "Accept-Charset", "value": "ISO-8859-1,utf-8;q=0.7,*;q=0.3" }, { "name": "Host", "value": "localhost:8080" }, { "name": "User-Agent", "value": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11" }, { "name": "Accept", "value": "*/*" }, { "name": "Referer", "value": "http://localhost:8080/" } ], "queryString": [], "cookies": [ { "name": "JSESSIONID", "value": "0A0475B4404B037CD2FDD8876A02285A", "expires": null, "httpOnly": false, "secure": false } ], "headersSize": 426, "bodySize": 0 }, "response": { "status": 405, "statusText": "Method Not Allowed", "httpVersion": "HTTP/1.1", "headers": [ { "name": "Date", "value": "Tue, 27 Nov 2012 08:38:32 GMT" }, { "name": "Content-Length", "value": "1045" }, { "name": "Server", "value": "Apache-Coyote/1.1" }, { "name": "Allow", "value": "POST" }, { "name": "Content-Type", "value": "text/html;charset=utf-8" } ], "cookies": [], "content": { "size": 1045, "mimeType": "text/html", "compression": 0 }, "redirectURL": "", "headersSize": 173, "bodySize": 1045 }, "cache": {}, "timings": { "blocked": 0, "dns": -1, "connect": -1, "send": 1, "wait": 6, "receive": 0, "ssl": -1 }, "pageref": "page_1" } </code></pre> <p>When I check the WAR file, the specific file is located inside WEB-INF/classes/images.</p> <p>I must be missing something, but this is driving me crazy. Anyone have any ideas?</p> <p><strong>Edit-</strong></p> <p>I have included my web.xml file here:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt; &lt;display-name&gt;a-Form Catering&lt;/display-name&gt; &lt;description&gt;a-Form Catering Web Site&lt;/description&gt; &lt;servlet&gt; &lt;servlet-name&gt;a-form&lt;/servlet-name&gt; &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;a-form&lt;/servlet-name&gt; &lt;url-pattern&gt;/&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;/web-app&gt; </code></pre> <p>my servlet file is actually a-form-servlet.xml</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload