问题
clinic example
I have change the contextPath in application.properties
:
server.contextPath=/tierklinik
When I start the application now the url is http://localhost:8080/tierklinik
, but when I will add something new (create) then I get error side and the URL is not correct.
Url after save:
http://localhost:8080/tierklinik/tierklinik/pets/
I have a normal spring boot application and the contextPath change work.
回答1:
This is a known problem in the Spring Roo 2.0.0.RC1 applications.
Check the <form>
element of your create.html
and edit.html
files. You could see that the action
attribute of the form is defined like this:
data-th-action="@{${collectionLink.to('create').with('item', item.id)}}"
Removing the @{
and the final }
you should obtain the following value for the action
attribute:
data-th-action="${collectionLink.to('create').with('item', item.id)}"
The problem is that the @
includes the contextPath in the URL, but the collectionLink
and the itemLink
includes it too.
If you want to apply this change to all your HTML views, you could update the .ftl
files instead the .html
files installing the templates with the command web mvc templates setup --type THYMELEAF
and updating them. After this update, opening the Spring Roo shell again, all your .html
files will be regenerated removing the @
from the action attribute.
Hope it helps,
Regards,
来源:https://stackoverflow.com/questions/44437623/spring-roo-2-0-0-rc1-problems-when-change-contextpath