title: Why in spring return ModelAndView prompting to download .json of view name?
body: <p>I have written a controller to navigate to a page named accessDenied.jsp.
  I am using Spring 4.3.6 version </p>
  
  <pre><code>@Controller
  public class BatchAccessDeniedController {
  
  static String ERRORPAGE = "accessDenied";
  
  public static final Logger LOG = Logger.getLogger(BatchAccessDeniedController.class);
  
  @RequestMapping(value = "/accessDenied" , method = RequestMethod.GET)
  public ModelAndView accessDenied(Principal user, ModelAndView modelAndView) {
  
      //Log the user who tried to access the restricted resource
      if (user != null) {
          LOG.info(user.getName() + " you do not have permission to access this page!");
      } else {
          LOG.info("You do not have permission to access this page!");
      }
      modelAndView.setViewName(ERRORPAGE);
      return modelAndView;
  }
  }
  </code></pre>
  
  <p>Everything works fine with the above code until I introduce Spring Batch Admin dependency and the batch admin configuration in web.xml as bellow</p>
  
  <pre><code>&lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;
          classpath:/root-context.xml,
          classpath*:/org/springframework/batch/admin/web/resources/webapp-config.xml,
          classpath:/config/spring-ldap-servlet.xml
      &lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;!-- Filter for Spring Security LDAP --&gt;
  &lt;filter&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter&gt;
      &lt;filter-name&gt;shallowEtagHeaderFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.ShallowEtagHeaderFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter&gt;
      &lt;filter-name&gt;hiddenHttpMethodFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.HiddenHttpMethodFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;shallowEtagHeaderFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;hiddenHttpMethodFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.util.Log4jConfigListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;runlauncher&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;
              classpath:/config/application-web-context.xml,
              classpath*:/org/springframework/batch/admin/web/resources/servlet-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;servlet-mapping&gt;
      &lt;servlet-name&gt;runlauncher&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt; 
  
  &lt;!-- Invalidate user session after 15 minutes of inactivity --&gt;
  &lt;session-config&gt;
      &lt;session-timeout&gt;15&lt;/session-timeout&gt;
  &lt;/session-config&gt;
  
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  </code></pre>
  
  <p>Batch admin dependency is as below</p>
  
  <pre><code>&lt;dependency&gt;
          &lt;groupId&gt;org.springframework.batch&lt;/groupId&gt;
          &lt;artifactId&gt;spring-batch-admin-manager&lt;/artifactId&gt;
          &lt;version&gt;${spring.batch.admin}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.batch&lt;/groupId&gt;
          &lt;artifactId&gt;spring-batch-admin-resources&lt;/artifactId&gt;
          &lt;version&gt;${spring.batch.admin}&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>By adding this, thought the control come to the BatchAccessDeniedController Class, it will prompt to download index.json file. I am not understanding why it is asking to download index.json file rather than redirecting to accessDenied.jsp page. Also I do have configuration for spring-ldap in which index.jsp is the default page after user login. </p>
  
  <p>I suspect something wrong with batch admin UI which is causing the issue. If someone has faced this similar issue, please help me getting rid of this.</p>
  
  <p>Here is the link for snapshot of the download icon displayed.
  <a href="https://i.stack.imgur.com/exQ9b.png" rel="nofollow noreferrer">index.json file</a></p>