title: Spring mvc Controller returns jsp code instead of jsp page
body: <p>my Spring mvc controller  returns Jsp code instead of jsp page </p>
  
  <p><strong>controller</strong></p>
  
  <pre><code>@RequestMapping(value="/authenticate")  
      public ModelAndView dashboard(HttpServletResponse response,HttpServletRequest request) throws IOException
      { 
          String username=request.getParameter("userName");
          String pws=request.getParameter("pws");
  
          System.out.println(username+pws); 
  
  
  
          return new ModelAndView("dashboard");       
      }
  </code></pre>
  
  <p>so, its returning whole <code>jsp code of dasboard</code>.</p>
  
  <p>but want to return a view jsp. why its returning code ?</p>
  
  <p><strong>web.xml</strong></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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;
    &lt;display-name&gt;Scheduling Portal&lt;/display-name&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;servlet&gt; 
      &lt;servlet-name&gt;spring&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;spring&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
    &lt;/listener&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>edit</strong></p>
  
  <p>if request is</p>
  
  <pre><code>@RequestMapping(value="/") 
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>@RequestMapping(value="/authenticate")
  </code></pre>
  
  <p>then it returns jsp page.</p>
  
  <p>i am adding servlet.xml to review it please get me a solution
  please look at <strong>servlet.xml</strong></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:context="http://www.springframework.org/schema/context"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xsi:schemaLocation="
          http://www.springframework.org/schema/beans 
          http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context.xsd
          http://www.springframework.org/schema/mvc
          http://www.springframework.org/schema/mvc/spring-mvc.xsd
          http://www.springframework.org/schema/tx 
          http://www.springframework.org/schema/tx/spring-tx.xsd
          http://www.springframework.org/schema/aop
          http://www.springframework.org/schema/aop/spring-aop.xsd"&gt;    
  
       &lt;!-- welcome page --&gt;
        &lt;mvc:view-controller path="/" view-name="login"/&gt; 
  
       &lt;!-- add AspectJ autoproxy support for AOP --&gt;
  
  
      &lt;aop:aspectj-autoproxy&gt;
          &lt;aop:include name="CmsLoggingAspect"/&gt;
      &lt;/aop:aspectj-autoproxy&gt;
  
      &lt;bean id="CmsLoggingAspect" class="com.rasvek.cms.aspect.CmsLoggingAspect"/&gt;  
  
      &lt;!-- Add support for component scanning --&gt;       
      &lt;context:component-scan base-package="com.rasvek.cms" &gt;
  
    &lt;/context:component-scan&gt;   
  
      &lt;!-- Add support for conversion, formatting and validation support --&gt;
      &lt;mvc:annotation-driven/&gt; 
  
      &lt;!-- Define Spring MVC view resolver --&gt;    
      &lt;bean
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix" value="/WEB-INF/views/" /&gt;
          &lt;property name="suffix" value=".jsp" /&gt;     
      &lt;/bean&gt; 
  &lt;mvc:resources mapping="/resources/**" location="/resources/" /&gt; 
      &lt;!-- Step 1: Define Database DataSource / connection pool --&gt;
      &lt;bean id="myDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
            destroy-method="close"&gt;
          &lt;property name="driverClass" value="com.mysql.jdbc.Driver" /&gt;
          &lt;property name="jdbcUrl" value="jdbc:mysql://localhost:3306/campus_guru_01?useSSL=false" /&gt;
          &lt;property name="user" value="root" /&gt;
          &lt;property name="password" value="root" /&gt;
  
        &lt;!--    &lt;property name="jdbcUrl" value="jdbc:mysql://aahbs06vwbadaq.ccmhxvps7vly.ap-south-1.rds.amazonaws.com:3306" /&gt;
          &lt;property name="user" value="CampusGuruDB" /&gt;
          &lt;property name="password" value="campusgurur" /&gt;   --&gt;   
  
          &lt;!-- these are connection pool properties for C3P0 --&gt;  
          &lt;property name="minPoolSize" value="5" /&gt;  
          &lt;property name="maxPoolSize" value="20" /&gt; 
          &lt;property name="maxIdleTime" value="30000" /&gt;    
      &lt;/bean&gt;    
  
      &lt;!-- Difine multipart Resolver for file upload --&gt;
       &lt;bean id="multipartResolver"
          class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
          &lt;!-- max upload size in bytes --&gt;
          &lt;property name="maxUploadSize" value="20971520" /&gt; &lt;!-- 20MB --&gt;
  
          &lt;!-- max size of file in memory (in bytes) --&gt;
          &lt;property name="maxInMemorySize" value="1048576" /&gt; &lt;!-- 1MB --&gt;
  
      &lt;/bean&gt;
  
      &lt;!-- Step 2: Setup Hibernate session factory --&gt; 
      &lt;bean id="sessionFactory"
          class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="myDataSource" /&gt;
          &lt;property name="packagesToScan" value="com.rasvek.cg.entity" /&gt;  
          &lt;property name="hibernateProperties"&gt;  
             &lt;props&gt;  
                &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;  
                &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
             &lt;/props&gt;
          &lt;/property&gt;
     &lt;/bean&gt;    
  &lt;tx:annotation-driven/&gt;   
      &lt;!-- Step 3: Setup Hibernate transaction manager --&gt;
      &lt;bean id="transactionManager"
              class="org.springframework.orm.hibernate5.HibernateTransactionManager"&gt;  
          &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
      &lt;/bean&gt;
  
      &lt;!-- Step 4: Enable configuration of transactional behavior based on annotations --&gt;
      &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
      &lt;mvc:default-servlet-handler/&gt;   
  
  &lt;/beans&gt;    
  </code></pre>
  
  <p>do i need to change anything in my servlet.xml  ?</p>