Note that there are some explanatory texts on larger screens.

plurals
  1. POShow jsp page inside jar file using Spring MVC
    primarykey
    data
    text
    <p>I'm developing a web application in java using Spring MVC 3.2.2. I'm having problems loading jsp page from within the jar file.</p> <p>The Sring MVC web application that the following structure:</p> <pre><code>|-META-INF |-WEB-INF |-spring | |- app-config.xml |-classes |-lib | |-external.jar | |-WEB-INF | | |-views | | |-external.jsp | |-classes | |-controller-for-external.class |-views |-... jsp </code></pre> <p>Config in app-config.xml</p> <pre><code> &lt;context:annotation-config /&gt; &lt;context:component-scan base-package="com" /&gt; &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; &lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView"&gt;&lt;/property&gt; &lt;property name="prefix" value="/WEB-INF/views/"&gt;&lt;/property&gt; &lt;property name="suffix" value=".jsp"&gt;&lt;/property&gt; &lt;/bean&gt; &lt;mvc:resources mapping="/views/**" location="classpath:/WEB-INF/views/" /&gt; &lt;mvc:annotation-driven /&gt; </code></pre> <p>Controller for external.jsp</p> <pre><code> @Controller public class ExternalController { protected final Log logger = LogFactory.getLog(getClass()); @RequestMapping(value="/external.htm") public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Map&lt;String, Object&gt; myModel = new HashMap&lt;String, Object&gt;(); myModel.put("msg", "External page loaded"); return new ModelAndView("external", "model", myModel); } </code></pre> <p>}</p> <p>web.xml file</p> <pre><code> &lt;web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt; &lt;display-name&gt;Springapp&lt;/display-name&gt; &lt;servlet&gt; &lt;servlet-name&gt;springapp&lt;/servlet-name&gt; &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/spring/app-config.xml&lt;/param-value&gt; &lt;/init-param&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/spring/app-config.xml&lt;/param-value&gt; &lt;/context-param&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;springapp&lt;/servlet-name&gt; &lt;url-pattern&gt;*.htm&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;/web-app&gt; </code></pre> <p>When a try to show external.jsp page, spring don't want search it and show error HTTP 404 - /springapp/WEB-INF/views/external.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