Grails 将页映射从控制器方法更改为显式视图页后,不会呈现消息
我将我的页面在UrlMappings中的映射更改为以下值:Grails 将页映射从控制器方法更改为显式视图页后,不会呈现消息,grails,message,Grails,Message,我将我的页面在UrlMappings中的映射更改为以下值: name producingCountry: "${adminArea}/producing-country/$id" (controller: "producingCountry", view: "/producingCountry/show") { constraints { id(matches: /\d+/) } } 页面(/producingCountry/show)简单如下: <%@ page content
name producingCountry: "${adminArea}/producing-country/$id" (controller: "producingCountry", view: "/producingCountry/show") {
constraints { id(matches: /\d+/) }
}
页面(/producingCountry/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>
如何解决此问题?使用此映射
"/${adminArea}/producing-country/$id" (controller: "producingCountry", view: "show")
当指定了控制器
时,视图
采用名称而不是相对路径
更新我不确定如何评估
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
当点击以下url模式时,给我一个标题为“美国”的页面:
http://localhost:8080/DemoUrlMappingApp/admin/producing-国家/地区/123
我认为在urlMapping定义中指定视图名称时不应指定控制器参数,请尝试以下操作:
"/${adminArea}/producing-country/$id" (view: "/producingCountry/show")
"/${adminArea}/producing-country/$id" (view: "/producingCountry/show")