Spring Roo 2.0.0.RC1 - Problems when change contextPath

时间秒杀一切 提交于 2019-12-13 03:49:38

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!