grails - 将页面映射从 Controller 方法更改为显式 View 页面后,不呈现消息

标签 grails message

我将UrlMappings中的页面映射更改为以下值:

name producingCountry: "${adminArea}/producing-country/$id" (controller: "producingCountry", view: "/producingCountry/show") {
    constraints { id(matches: /\d+/) }
}

页面(/ productionCountry / show)很简单:
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <meta name="layout" content="main">
    <title><g:message code="producingCountry.show.title"/></title>
</head>
<body>

</body>
</html>

该消息不再呈现。当其url映射到 Controller 方法“show”(最后一行)时,它运行良好:
render [producingCountry: (country)]

如何解决此问题?

最佳答案

使用此映射

"/${adminArea}/producing-country/$id" (controller: "producingCountry", view: "show")

当指定了controller时,view将使用名称而不是相对路径。

更新
我不确定adminArea的评估方式,但是以下内容对我有用:
//UrlMapping:- [mark the "/" in the beginning of the mapping, it is required to append to root context]
name producingCountry: "/admin/producing-country/$id" (controller: "producingCountry", view: "show") {
                constraints { id(matches: /\d+/) }
        }

//show.gsp
Exactly same (copied) from your question.

//messages.properties
producingCountry.show.title=United States

按下以下网址格式时,给我一个标题为United States的页面:
http://localhost:8080/DemoUrlMappingApp/admin/producing-country/123

关于grails - 将页面映射从 Controller 方法更改为显式 View 页面后,不呈现消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16876824/

相关文章:

grails - chrome中的Geb单选按钮不起作用

validation - 如何执行已验证的Grails命令对象?

java - java try/catch 的问题

validation - 验证未在 1905 Backoffice 中显示的拦截器错误消息

android - 我如何发送 WAP 推送消息?

jquery - 如何在jquery-file-upload响应中传回ID?

sql - 来自 grails 项目的 hibernate AssertionFailure

grails - 为什么g是:link ignoring request params?

android - 如何从 smack 中的消息 ID 获取消息。

c++ - ROS C++ catkin 找不到我的自定义消息