我正在尝试将一个较旧的 java 项目设置并重新设计为 grails。我使用 GGTS 3.1.0.Release 并配置了我的域模型。我的问题是,当我使用自动生成控制器和视图时(右键单击项目->新建->生成控制器和视图),它确实生成了文件,但属性并不全部包含在内!我认为这个脚手架可以提供一个包含我的域类的所有属性的视图。我错了吗?
副班:
package com.trading.core
class Associate {
Integer id
String name
String address
Prefecture prefecture
SubPrefecture subPrefecture
Municipal municipal
String city
BigDecimal minDiscount
String zipcode
User insUser
Date insDatetime
User updtUser
Date updtDatetime
static mapping = {
table "associate"
id generator: 'identity'
minDiscount column:"min_discount"
insUser column: "ins_user"
insDatetime column: "ins_datetime"
updtUser column: "updt_user"
updtDatetime column: "updt_datetime"
municipal column: "municipal"
subPrefecture column: "sub_prefecture"
prefecture column: "prefecture"
version false
}
static constraints = {
}
}
list.gsp(生成)
<%@ page import="com.trading.core.Associate" %>
<!DOCTYPE html>
<html>
<head>
<meta name="layout" content="main">
<g:set var="entityName" value="${message(code: 'associate.label', default: 'Associate')}" />
<title><g:message code="default.list.label" args="[entityName]" /></title>
</head>
<body>
<a href="#list-associate" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content…"/></a>
<div class="nav" role="navigation">
<ul>
<li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
<li><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
</ul>
</div>
<div id="list-associate" class="content scaffold-list" role="main">
<h1><g:message code="default.list.label" args="[entityName]" /></h1>
<g:if test="${flash.message}">
<div class="message" role="status">${flash.message}</div>
</g:if>
<table>
<thead>
<tr>
<g:sortableColumn property="name" title="${message(code: 'associate.name.label', default: 'Name')}" />
<g:sortableColumn property="address" title="${message(code: 'associate.address.label', default: 'Address')}" />
<g:sortableColumn property="city" title="${message(code: 'associate.city.label', default: 'City')}" />
<g:sortableColumn property="insDatetime" title="${message(code: 'associate.insDatetime.label', default: 'Ins Datetime')}" />
<th><g:message code="associate.insUser.label" default="Ins User" /></th>
<g:sortableColumn property="minDiscount" title="${message(code: 'associate.minDiscount.label', default: 'Min Discount')}" />
<th><g:message code="associate.municipal.label" default="Municipal" /></th>
</tr>
</thead>
<tbody>
<g:each in="${associateInstanceList}" status="i" var="associateInstance">
<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
<td><g:link action="show" id="${associateInstance.id}">${fieldValue(bean: associateInstance, field: "address")}</g:link></td>
<td>${fieldValue(bean: associateInstance, field: "city")}</td>
<td><g:formatDate date="${associateInstance.insDatetime}" /></td>
<td>${fieldValue(bean: associateInstance, field: "insUser")}</td>
<td>${fieldValue(bean: associateInstance, field: "minDiscount")}</td>
<td>${fieldValue(bean: associateInstance, field: "municipal")}</td>
</tr>
</g:each>
</tbody>
</table>
<div class="pagination">
<g:paginate total="${associateInstanceTotal}" />
</div>
</div>
</body>
</html>