Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring + Tiles - 404 error when accessing jsp folder
    primarykey
    data
    text
    <p>Basically, what happens when I launch my project is that the views are all resolved properly and the correct jsp is being looked for, however there seems to be something blocking tiles access to my jsp folder inside the WEB-INF folder.</p> <p>The exact problem is that when I go to localhost/FitterBlog/index.htm I get a 404 error:</p> <pre><code>The requested resource (/FitterBlog/jsp/layout/layout.jsp) is not available. </code></pre> <p>I have the following code:</p> <p>web.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app version="3.0" 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_3_0.xsd"&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/applicationContext.xml&lt;/param-value&gt; &lt;/context-param&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;servlet&gt; &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt; &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt; &lt;load-on-startup&gt;2&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt; &lt;url-pattern&gt;*.htm&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;session-config&gt; &lt;session-timeout&gt;30&lt;/session-timeout&gt; &lt;/session-config&gt; &lt;welcome-file-list&gt; &lt;welcome-file&gt;redirect.jsp&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;/web-app&gt; </code></pre> <p>dispatcher-servlet.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt; &lt;context:component-scan base-package="com.fitterblog.controllers"/&gt; &lt;context:annotation-config/&gt; &lt;!-- tiles configuration --&gt; &lt;bean id="tilesViewResolver" 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 id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"&gt; &lt;property name="definitions"&gt; &lt;list&gt; &lt;value&gt;/WEB-INF/tiles.xml&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <p>tiles.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN" "http://tiles.apache.org/dtds/tiles-config_2_0.dtd"&gt; &lt;tiles-definitions&gt; &lt;definition name="baseLayout" template="/jsp/layout/layout.jsp"&gt; &lt;put-attribute name="title" value="FitterBlog" /&gt; &lt;put-attribute name="header" value="/jsp/layout/header.jsp" /&gt; &lt;put-attribute name="nav" value="/jsp/layout/nav.jsp" /&gt; &lt;put-attribute name="body" value="" /&gt; &lt;put-attribute name="footer" value="/jsp/layout/footer.jsp" /&gt; &lt;/definition&gt; &lt;definition name="index" extends="baseLayout"&gt; &lt;put-attribute name="body" value="/jsp/index.jsp" /&gt; &lt;/definition&gt; &lt;/tiles-definitions&gt; </code></pre> <p>MainController.java:</p> <pre><code>package com.fitterblog.controllers; 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 public class MainController { @RequestMapping(value="index.htm", method=RequestMethod.GET) public ModelAndView index() { return new ModelAndView("index"); } } </code></pre> <p>I have triple checked that all the JSP files are located in the correct location, as in the layout.jsp file that gets the 404 error is located in WEB-INF/jsp/layout/layout.jsp.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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