Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it supposed to work on JSP pages in Spring Boot? #10

Open
kerdosmedia opened this issue Feb 7, 2020 · 2 comments
Open

Is it supposed to work on JSP pages in Spring Boot? #10

kerdosmedia opened this issue Feb 7, 2020 · 2 comments

Comments

@kerdosmedia
Copy link

I have a spring-boot web application running as a war file on tomcat using JSP's for templates.

If I try to output the UUID in my JSP using something like ${myObject.id} it displays the UUID.

Other things are working properly. If I put the converted UUID in the URL it gets converted. If I use the Spring Form tags using something like <form:input path="id" type="hidden"/> it gets converted to a friendly ID and when posting the form

I created a tag to do the conversion but was wondering if there was a better way?

@mariuszs
Copy link
Member

mariuszs commented Sep 2, 2020

Sorry, I'm not using JSP for long time. I don't know if there is a better way :(

@mariogarcia
Copy link

I've done a proof of concept with friendly-id with spring with both server pages and rest endpoints, and for rendering friendly-ids in my server rendered pages, I had to use DTOs instead of passing directly domain objects. Here's an example, whenever I need to pass model attributes to pages, I'm converting to DTOs:

spring-mvc-controller

And in the mappers (I'm using mapstruct), every time there is an UUID to be converted to String, the mappers have to use Friendly-Id to do the conversion:

mapstruct-mappers

Controllers are ok when you are expecting UUIDs, and they receive a friendly-id, they do the conversion ok, but, you have to be careful with redirections, then you have to explicitly convert the id to build the url string chain.

Screenshot from 2021-12-12 12-51-24

In this example the **bookService.createBook(...)" returns an UUID, so I have to convert it explicitly in order to get the expected shorten url.

I hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants