gpt4 book ai didi

grails - Grails 重定向到GSP而不是操作

转载 作者:行者123 更新时间:2023-12-02 15:15:06 25 4
gpt4 key购买 nike

我在类似于更新的 Controller “X”上创建了一个名为“updateWithHistory”的新 Action 。当我从脚手架的edit.gsp页面使用此代码时:
<span class="button"><g:actionSubmit class="save" action="updateWithHistory" value="${message(code: 'default.button.updateWithHistory.label', default: 'Persist')}" /></span>
我收到404错误:
The requested resource (/GPECAN/WEB-INF/grails-app/views/X/updateWithHistory.jsp) is not available.
我不知道为什么Grails在寻找 View 而不是在寻找 Action 。我不需要该操作的 View ,因为它重定向到现有操作(列表,编辑等)。

对于默认的脚手架操作(例如“更新”),不会发生这种情况。有任何想法吗?

(当然,如果我创建一个名为“updateWithHistory.gsp”的 View ,则会显示该 View ,但是该操作永远不会执行...我很拼命)

最佳答案

有两种方法可以解决问题,具体取决于要实现的目标。
您必须知道的第一件事是文档中的报价:

Also note that this tag relies on the multipart resolver to be able to inspect parameters included with mulitpart requests. If you disable the resolver by setting grails.disableCommonsMultipart to true in Config.groovy, actionSubmit will not work.



有两种解决方案:
  • g:form tag中设置'controller'属性
  • 创建URL映射为described here

  • 附言如果要通过浏览器查看任何“可渲染”结果,则必须使用 Controller 的动态 渲染方法:)

    关于grails - Grails <g:actionSubmit>重定向到GSP而不是操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3476274/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com