【问题标题】:Spring Roo 2.0.0.RC1 - Problems when change contextPathSpring Roo 2.0.0.RC1 - 更改 contextPath 时的问题
【发布时间】:2017-06-08 13:51:24
【问题描述】:

诊所示例

我已经更改了application.properties 中的 contextPath:

server.contextPath=/tierklinik

当我现在启动应用程序时,url 是 http://localhost:8080/tierklinik,但是当我添加新的东西(创建)时,我得到了错误,并且 URL 不正确。

保存后的网址:

http://localhost:8080/tierklinik/tierklinik/pets/

我有一个正常的 Spring Boot 应用程序,并且 contextPath 更改工作正常。

【问题讨论】:

    标签: spring-roo


    【解决方案1】:

    这是 Spring Roo 2.0.0.RC1 应用程序中的一个已知问题。

    检查create.htmledit.html 文件的<form> 元素。您可以看到表单的action 属性是这样定义的:

    data-th-action="@{${collectionLink.to('create').with('item', item.id)}}"
    

    删除@{ 和最后的},您应该获得action 属性的以下值:

    data-th-action="${collectionLink.to('create').with('item', item.id)}"
    

    问题是@ 在 URL 中包含 contextPath,但 collectionLinkitemLink 也包含它。

    如果您想将此更改应用到所有 HTML 视图,您可以更新 .ftl 文件而不是 .html 文件,使用命令 web mvc templates setup --type THYMELEAF 安装模板并更新它们。此次更新后,再次打开 Spring Roo shell,将重新生成所有 .html 文件,从操作属性中删除 @

    希望对你有帮助,

    问候,

    【讨论】:

    • 如果它解决了你的问题,记得验证答案;)问候
    猜你喜欢
    • 2017-12-29
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 2018-01-04
    • 1970-01-01
    • 1970-01-01
    • 2018-07-19
    • 1970-01-01
    相关资源
    最近更新 更多