Results 1 to 2 of 2

Thread: @PathVariable not resolving

  1. #1
    Join Date
    Jun 2008
    Posts
    12

    Default @PathVariable not resolving

    Spring Community,
    I have an issue that appears to have been asked before, but not resolved. I have of course done my due diligence. However, I can't find the answer.

    Why does the following never resolve when I perform a PUT on the URL?

    Code:
    @RequestMapping(value = "/sensor/add/{name}/{type}/{location}", method=RequestMethod.PUT,produces = "application/json")
    	public @ResponseBody
    	ResponseEntity<String> test(@PathVariable("name") String name,
    			@PathVariable("type") String type, 
    			@PathVariable("location") String location, 
    			HttpServletRequest request,
    			HttpServletResponse response) {
    		HttpHeaders headers = new HttpHeaders();
    		headers.add("Content-Type", "application/json");
    		System.err.println("Made it: " + name + " " + type + " ");
    
    		return new ResponseEntity<String>(headers, HttpStatus.ACCEPTED);
    	}
    Using the URL "http://localhost:8080/ABServer/sensor/add/testname/testtype/testlocation" spring mvc does not resolve the URL, but instead goes to the Index page.

    In addition, if I remove the "location" variable, it works just fine (Much the same as the previously unanswered question). I've read the appropriate documentation and do not see a limit to the number of variables. In addition, the URL is certainly unique.

    Thoughts? What am I missing?

    Thanks

  2. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,806

    Default

    Hello

    What happen if you use RequestMethod.GET or RequestMethod.POST?
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •