Sunday 15 August 2010

Spring MVC REST -


I am using Spring MVC and give this example with a controller mapped to a URL. I also have a method that has been shown to help me see my examples based on an example I @RequestMapping ("/ Example") @RequestMapping (value = "/ {ID}", output = " Text / html ") public string show (@path variable (" id ") string id, model model) {// do some stuff and come back a view}

The problem is that ID is a URI and has a forward slash (for example test / case / version / sample one coming) ED can be, resulting in URL example / test / case / version / sample). Therefore my application gives me an error "not received the requested resource". I can not easily change the format of these IDs. This is the list given to me which I have to work with. Is there a way around this? Thanks in advance.

You can try to use regular expressions on @roth varible.

From the Spring Doc like this:

  @RequestMapping ("/ spring-web / {symbolic name: [az -] +} - {version: \\ d \\ . \\ d \ \. \\ d} {extension: \\. [Az] +} "Public Zero Handle (@ Pathworthy String Version, @PathVariable String Extension) {// ...}}   

You will only need to consider a regular expression that matches the "example / trial / case / edition / sample" which is your expression.

See the title: "URI template patterns with regular expressions" on this page: For more information

No comments:

Post a Comment