spring-projects / spring-data-commons

Spring Data Commons. Interfaces and code shared between the various datastore specific implementations.
https://spring.io/projects/spring-data
Apache License 2.0
774 stars 674 forks source link

@EnableSpringDataWebSupport and Spring 4.1 mvcUrl JSP tag are difficult to combine [DATACMNS-573] #1040

Open spring-projects-issues opened 10 years ago

spring-projects-issues commented 10 years ago

Hans Desmet opened DATACMNS-573 and commented

@EnableSpringDataWebSupport allows to specify an entity where the browsers sends an entity identifier:

@Controller
class ClientController {
  @RequestMapping(value = "/clients/{client}", method = RequestMethod.GET)
  ModelAndView get(@PathVariable Client client) {
  }
}

accepts a request to /clients/1 and converts 1 to the {8Client}} entity with id 1 by reading this entity from the database.

You can however not refer to this method with the new mvcUrl JSP tag in Spring 4.1:

${s:mvcUrl('CC#get').arg(0,1).build()}

because you feed the first parameter an Integer value 1, which is not compatible with real the type of the parameter Client and mvcUrl does not know about the automatic conversion provided by @EnableSpringDataWebSupport.


Affects: 1.8.4 (Dijkstra SR4)

spring-projects-issues commented 9 years ago

Oliver Drotbohm commented

What's the reason you don't hand a Client instance to the arg(…) method? That wouldn't require a conversion at all then, would it?

Rossen Stoyanchev - Does the mvcUrl tag not consider the ConversionService for potentially matching conversions? That's the way we integrate on actual requests with MVC so I would've expected a similar binding to happen for the JSP tag usage

spring-projects-issues commented 9 years ago

Rossen Stoyanchev commented

Currently we don't. I suppose we could try to hook that in

spring-projects-issues commented 9 years ago

Hans Desmet commented

Hello Oliver,

I created a litte sample project that uses your suggestion: hand a Client instance to the arg(...) method. You can clone it from https://github.com/desmethans/mvcurl.git It leads to a java.lang.IllegalArgumentException: The source to convert from must be an instance of long; instead it was a be.vdab.entities.Client. Hope it helps to understand and solve the problem