Resource oriented design

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Resource oriented design


The controller code in Spring 4.1.6 looks like this:

@RequestMapping(value = "/event/details/{id}", method = RequestMethod.GET)
        public String doSelectUniqueEventTh(@PathVariable int id, Model model) {
               
                model.addAttribute(eventService.getEventByID(id));
               
                return "the relevant details";
               
        }

Is there a way of managing resources in the way I require rather than Thymeleaf returning 'details?id=1'

Many thanks and best regards

Beagle
beagle
Hello,

I am developing a simple Spring MVC application using Thymeleaf 2.1.4.

I wish to create a resource oriented design, as far as possible, so for example rather than returning a URL from the controller that looks like this:

http://localhost:8080/VladJP2Events/event/details?id=1

I wish to return a URL that looks like this

http://localhost:8080/VladJP2Events/event/details/1

The entry in the view template looks like this:

Reply | Threaded
Open this post in threaded view
|

Re: Resource oriented design


Regards
beagle
The entry in the view template looks like this (missing from the original post):

Reply | Threaded
Open this post in threaded view
|

Re: Resource oriented design

Zemi
Administrator
Hi,

you can put code inside raw tags in order to display it properly in the forums.

BTW, you can use different styles to build REST-style URIs, like

     @{/product/__${id}__}

     @{|/product/${id}|}

     @{'/product/' + ${id}}

Regards,
   Zemi

Reply | Threaded
Open this post in threaded view
|

Re: Resource oriented design

beagle
Hi Zemi,

That has fixed my problem.

Many thanks for taking the time to respond, greatly appreciated.

Regards

The Scottish Beagle