I have a simple page called headers.jsp in my Spring-MVC (4.1.5.RELEASE) web-app which i would like to call up from my index page like this:
<body>
<c:url value="/headers" var="headersUrl1"/>
<c:url value="/headers.jsp" var="headersUrl2"/>
<c:url value="/headers.jspx" var="headersUrl3"/>
<ul>
    <li><a href="${headersUrl1}">Works!</a></li>
    <li><a href="${headersUrl2}">Does not work!</a></li>
    <li><a href="${headersUrl3}">Does not work!</a></li>
</ul> 
The first url (to /headers) works fine but the other two (with suffix .jsp/jspx) do not; result is a 404. I have a need for the links to work (in real life they come from a legacy database which i have to use). I have spent quite some time googling but found no solution as yet. The requests to links are handled by the following controller code:
@Controller
public class HeadersViewController {
@RequestMapping(value = {"/headers"}, method = RequestMethod.GET)
public String getHeadersPage() {
    return "headers";
}
@RequestMapping(value = {"/headers**"}, method = RequestMethod.GET)
public String getHeaderPages() {
    return "headers";
}
@RequestMapping(value = {"/headers.jspx"}, method = RequestMethod.GET)
public String getHeaderPageJspx() {
    return "headers";
}
@RequestMapping("/{name}.jspx")
public String getPageByName(@PathVariable("name") String name) {
    return name;
}
}
None of the controller methods get called when requesting /headers.jsp or /headers.jspx.
Strangely enough when using spring-test and mock-mvc they do get fired and tests to check the mentioned url`s passes. Any help greatly appreciated! The rest of the config code is given below.
Dispatcherservlet init:
public class DispatcherServletInitializer extends
    AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
    return new Class<?>[] { SecurityConfiguration.class, WebMvcConfiguration.class };
}
@Override
protected Class<?>[] getServletConfigClasses() {
    return new Class<?>[] { };
}
@Override
protected String[] getServletMappings() {
    return new String[] { "/" };
}
@Override
protected Filter[] getServletFilters() {
    return new Filter[] { new HiddenHttpMethodFilter() };
}
}
MvcConfiguration:
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = {"nl.demo.web.controller"})
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/").setViewName("index");
    registry.addViewController("/index").setViewName("index");
    registry.addViewController("/login");
    registry.addViewController("/logout");
}
@Bean 
public InternalResourceViewResolver viewResolver() {
      InternalResourceViewResolver viewResolver=new InternalResourceViewResolver();
      viewResolver.setViewClass(JstlView.class);
      viewResolver.setPrefix("/WEB-INF/");
      viewResolver.setSuffix(".jsp");
      viewResolver.setOrder(0);
      return viewResolver;
}
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
}
 }
Security config:
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
    web
        .ignoring()
            .antMatchers("/images/**", "/js/**", "/css/**", "/fonts/**");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
    http
        .authorizeRequests()
            .anyRequest().authenticated()
            .and()
        .formLogin()
            .loginPage("/login")
            .defaultSuccessUrl("/index")
            .failureUrl("/login?error=1")
            .permitAll()
            .and()
        .httpBasic()
            .and()
        .logout()
            .logoutUrl("/logout")
            .logoutSuccessUrl("/login?logout=1")
            .permitAll();
}
@Autowired
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    String user = "test";
    String password = "blabla";
    String[] roleList = "USER,SUPERVISOR".split(",");
    auth.inMemoryAuthentication()
        .withUser(user)
        .password(password)
        .roles(roleList);
}
}
 
     
     
    