grails 控制器渲染错误
class Person {
String name
Integer age
String street
String email
}
class PersonController {
def save = {
def personInstance = new Person(params)
personInstance.save(flush:true)
}
}
main.gsp
<g:form controller="person" action="save">
<g:textField name="name" />
<g:textField name="age" />
<g:textField name="street" />
<g:textField name="email" />
<g:submitButton name="save" value="Save" />
</g:form>
我必须在控制器和 gsp 页面中进行哪些修改才能将错误呈现到 gsp 页面?
class Person {
String name
Integer age
String street
String email
}
class PersonController {
def save = {
def personInstance = new Person(params)
personInstance.save(flush:true)
}
}
main.gsp
<g:form controller="person" action="save">
<g:textField name="name" />
<g:textField name="age" />
<g:textField name="street" />
<g:textField name="email" />
<g:submitButton name="save" value="Save" />
</g:form>
What modifications do i have to make in both the controller and the gsp page to render the errors to the gsp page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将控制器操作更改为
并将其添加到
之前:考虑运行
grailsgenerate-all packagename.Person
并编辑生成的控制器和 GSP。当然,先把你的移开。Change the controller action to
and add this just before your
<g:form>
:Consider running
grails generate-all packagename.Person
and editing the generated controller and GSPs. Of course move yours out of the way first.您必须设置:
查看:
或:
You have to set either:
View:
Or: