Announcement Announcement Module
Collapse
No announcement yet.
@PathVariable problem URI Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @PathVariable problem URI

    Hello I have created an AppConfig for the jsp path in the follow way:

    Code:
    package com.amadeus.spring.controllers;
    
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.web.servlet.ViewResolver;
    import org.springframework.web.servlet.view.InternalResourceViewResolver;
    
    import com.amadeus.services.SearchServiceI;
    import com.amadeus.services.SearchServiceImpl;
    
    @Configuration
    public class AppConfig {
    
    	// Resolve logical view names to .jsp resources in the /WEB-INF/views directory
    	@Bean
    	ViewResolver viewResolver() {
    		InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    		resolver.setPrefix("WEB-INF/views/");
    		resolver.setSuffix(".jsp");
    		return resolver;
    	}
    	
        @Bean
        public SearchServiceI searchService() {
            return new SearchServiceImpl();
        }
        
    }
    Then I have tryied to use @PathVariable
    Code:
    	
    @RequestMapping(value="/getProperty/{propertyID}", method = RequestMethod.GET)
    	public String getPropertyDetails(@PathVariable String propertyID, @ModelAttribute("resultSet") HashMap<Integer, Property> resultSetInSession,Model model){
    		Property p=resultSetInSession.get(new Integer(propertyID));
    		model.addAttribute("propertyToShowDetails",p);
    		return "details";
    		
    	}
    and I receive : HTTP Status 404 - /cat/getProperty/WEB-INF/views/details.jsp

    why? So if I cannot differanziate the requestes which is the scop of @RequestMapping?
    thank you
    Daniele

  • #2
    Have you actually looked at the URL? The problem is you misconfigured the view resolver. It should start with a / so /WEB-INF not WEB-INF. If you leave out the / it is a relative path and not an absolute path.

    Comment

    Working...
    X