title: servlet-mapping and spring InternalResourceViewResolver: which controls what mapping?
body: <p>My configuration looks like this:</p>
  
  <h2>web.xml</h2>
  
  <pre><code>&lt;web-app 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"
        version="2.5"&gt;    
  
  &lt;display-name&gt;Demo Web Application&lt;/display-name&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;mvc-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;mvc-dispatcher&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;filter&gt;
      &lt;filter-name&gt;hibernateFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.orm.hibernate3.support.OpenSessionInViewFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;hibernateFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/mvc-dispatcher-servlet.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;/web-app&gt;
  </code></pre>
  
  <h2>mvc-dispatcher-servlet.xml</h2>
  
  <pre><code>&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" xmlns:p="http://www.springframework.org/schema/p"
  xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc"
  xsi:schemaLocation="
      http://www.springframework.org/schema/beans     
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/context 
      http://www.springframework.org/schema/context/spring-context-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/mvc 
      http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"&gt;
  
  &lt;tx:annotation-driven /&gt;
  &lt;mvc:annotation-driven /&gt;
  
  &lt;context:component-scan base-package="com.company.controller" /&gt;
  &lt;context:component-scan base-package="com.company.service" /&gt;
  &lt;context:component-scan base-package="com.company.dao" /&gt;
  &lt;context:component-scan base-package="com.company.hibernate" /&gt;
  
  &lt;bean id="propertyConfigurer"
  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
      p:location="/WEB-INF/jdbc.properties" /&gt;
  
  &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
      destroy-method="close"&gt;
      &lt;property name="driverClassName" value="${jdbc.driverClassName}" /&gt;
      &lt;property name="url" value="${jdbc.databaseurl}" /&gt;
      &lt;property name="username" value="${jdbc.username}" /&gt;
      &lt;property name="password" value="${jdbc.password}" /&gt;
      &lt;property name="validationQuery" value="SELECT 1" /&gt;
      &lt;property name="testOnBorrow" value="true" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="configLocation"&gt;
          &lt;value&gt;/WEB-INF/hibernate.cfg.xml&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="configurationClass"&gt;
          &lt;value&gt;org.hibernate.cfg.AnnotationConfiguration&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hbm2ddl.auto"&gt;update&lt;/prop&gt;
              &lt;prop key="hibernate.dialect"&gt;${jdbc.dialect}&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="transactionManager"
      class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;bean
      class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;property name="prefix"&gt;
          &lt;value&gt;/WEB-INF/pages/&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="suffix"&gt;
          &lt;value&gt;.jsp&lt;/value&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>My controller code looks like this:</p>
  
  <h2>PersonController2.java</h2>
  
  <pre><code>package com.company.controller;
  
  @Controller
  @RequestMapping("rest")
  public class PersonController2 {
  
  @Autowired
  private PersonService personService;
  
  @RequestMapping(value = "list", method = RequestMethod.GET)
  public @ResponseBody
  List&lt;Person&gt; listAction() {
      return personService.listPerson();
  }
  
  @RequestMapping(value = "ajax", method = RequestMethod.GET)
  public @ResponseBody
  String ajaxAction() {
      return "ajax";
  }
  }
  </code></pre>
  
  <h2>WEB-INFO/pages/index.jsp</h2>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%&gt;
  
  &lt;%@ taglib prefix="c" 
         uri="http://java.sun.com/jsp/jstl/core" %&gt;
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;style&gt;
  table,th,td
  {
  border:1px solid black;
  background-color:#00FF00;
  }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;table align="center"&gt;
      &lt;tr&gt;
          &lt;td style="text-decoration: blink"&gt;
          &lt;a href="/myprj/ajax"&gt;
      A simple page using Spring 3 restful service, ajax and AngularJS&lt;/a&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <h2>WEB-INFO/pages/ajax.jsp</h2>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="en" ng-app id="ng-app"&gt;
  &lt;head&gt;
  &lt;title&gt;My Page&lt;/title&gt;
  &lt;script src="scripts/angular.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  function AjaxGet($scope, $http) {
      $http({
          method : 'GET',
          url : 'myprj/rest/list'
      }).success(function(data) {
          $scope.persons = data; // response data 
      });
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="ng-app" ng-app ng-controller="AjaxGet"&gt;
  
      &lt;div ng-repeat="person in persons"&gt;
          &lt;h2&gt;
              &lt;a href='{{person.firstName}}'&gt;&lt;/a&gt;
          &lt;/h2&gt;
      &lt;/div&gt;
  
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>when I hit rest/list, it returns JSON just fine. All my JSPs are in WEB-INF/pages including ajax.jsp which will call rest/list and parse the returned JSON. What I can't figure out is how to invoke ajax.jsp. Any help would be greatly appreciated.</p>