Note that there are some explanatory texts on larger screens.

plurals
  1. PONot able to run spring application using XML configuration
    primarykey
    data
    text
    <p>I am new to spring, trying to run the Spring application through XML configuration, but i am not getting any error in console. But the application is not running and i am getting the 404 error. I didn't add the servlet-api jar in WEB-INF/lib. Can anyone please help me? Thanks in advance.</p> <pre><code> package com.raistudies.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.AbstractController; public class HelloWorldAction extends AbstractController { @Override protected ModelAndView handleRequestInternal(HttpServletRequest arg0, HttpServletResponse arg1) throws Exception { System.out.println(" helloworld... "); ModelAndView mav = new ModelAndView(); mav.setViewName("hello"); mav.addObject("helloMessage", "Hello World from My First Spring 3 mvc application with xml configuration..."); return mav; } } </code></pre> <p>hello.jsp - WEB-INF/jsp/</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Hello World with spring 3 MVC XML configuration&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Welcome! Spring MVC XML configuration is working well&lt;/h1&gt; ${helloMessage} &lt;/body&gt; &lt;/html&gt; </code></pre> <p>index.jsp - WEB-INF</p> <pre><code> &lt;html&gt; &lt;head&gt; &lt;title&gt;rai studies&lt;/title&gt; &lt;/head&gt; &lt;body&gt; Welcome... &lt;a href="hello"&gt;&lt;br&gt;Click here to check the output :-)&lt;/a&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>web.xml</p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID_1" version="3.0"&gt; &lt;display-name&gt;HWEWS3MVCIEA&lt;/display-name&gt; &lt;servlet&gt; &lt;servlet-name&gt;SpringMVCDispatcherServlet&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/app-config.xml&lt;/param-value&gt; &lt;/init-param&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;SpringMVCDispatcherServlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;welcome-file-list&gt; &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;/web-app&gt; </code></pre> <p>app-config.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"&gt; &lt;bean name="/hello.htm" class="com.raistudies.action.HelloWorldAction" /&gt; &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt; &lt;property name="suffix" value=".jsp" /&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <p>libraries under the WEB-INF/lib</p> <ul> <li>commons-logging-1.1.2.jar</li> <li>jstl-1.2.jar</li> <li>log4j-1.2.16.jar</li> <li>spring-aspects-3.2.5.RELEASE.jar</li> <li>spring-beans-3.2.5.RELEASE.jar</li> <li>spring-context-3.2.5.RELEASE.jar</li> <li>spring-core-3.2.5.RELEASE.jar</li> <li>spring-expression-3.2.5.RELEASE.jar</li> <li>spring-web-3.2.5.RELEASE.jar</li> <li>spring-webmvc-3.2.5.RELEASE.jar</li> </ul> <p>supportingLibrary under WEB-INF/supportingLibrary</p> <ul> <li>servlet-api-2.5.jar</li> </ul>
    singulars
    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