Groovy Grails操作被调用两次。帮助
我正在编写一个grails应用程序,遇到了一个奇怪的问题。单击页面上的submit按钮时,关联的操作会连续快速调用两次。这就导致了所有的东西都被严重破坏。以前有人见过这个问题吗?下面是我的代码: 从普惠制页面:Groovy Grails操作被调用两次。帮助,groovy,gsp,grails,Groovy,Gsp,Grails,我正在编写一个grails应用程序,遇到了一个奇怪的问题。单击页面上的submit按钮时,关联的操作会连续快速调用两次。这就导致了所有的东西都被严重破坏。以前有人见过这个问题吗?下面是我的代码: 从普惠制页面: <g:form method="post" action="show"> <h2>All items since...</h2> <g:datePicker name="startDate" precision="day" value="${ne
<g:form method="post" action="show">
<h2>All items since...</h2>
<g:datePicker name="startDate" precision="day" value="${new Date()}" /><br/>
<h2>Format</h2>
<g:radio name="feedType" value="RSS1" checked="true"/><span>RSS 1.0</span>
<g:radio name="feedType" value="RSS2"/><span>RSS 2.0</span>
<g:radio name="feedType" value="ATOM"/><span>Atom</span><br/>
<hr />
<h2>Topics</h2>
<g:each in="${list}" var="subscription" status="i">
<g:if test="${i == 0}">
<g:radio name="nodeID" value="subscription.name" checked="true"/><span>${subscription.getPrettyName()}</span><br/>
</g:if>
<g:else>
<g:radio name="nodeID" value="${subscription.name}"/><span>${subscription.getPrettyName()}</span><br/>
</g:else>
</g:each>
<hr/>
<g:submitButton name="getFeedButton" value="Get Feed!" />
所有项目自。。。
总体安排
RSS 1.0
RSS 2.0
原子
话题
${subscription.getPrettyName()}
${subscription.getPrettyName()}
从控制器:
def show = {
def nodeID = params.nodeID
def feedType
if(params.feedType.equals("RSS1")){
feedType = FeedType.RSS1;
} else if(params.feedType.equals("RSS2")){
feedType = FeedType.RSS2;
} else{
feedType = FeedType.ATOM;
}
def date = params.startDate
println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
println(date)
println("Time "+System.currentTimeMillis());
println("****************************")
def feed = XMPPListenerService.getFeed(date, feedType, nodeID)
response.contentType = "text/xml"
response.outputStream << feed;
}
def show={
def nodeID=params.nodeID
def馈线类型
if(参数feedType.equals(“RSS1”)){
feedType=feedType.RSS1;
}else if(参数feedType.equals(“RSS2”)){
feedType=feedType.RSS2;
}否则{
feedType=feedType.ATOM;
}
def date=参数startDate
println(“!!!!!!!!!!!!!!!!!!!!!!!!!”)
println(日期)
println(“Time”+System.currentTimeMillis());
println(“*******************************”)
def feed=XMPPListenerService.getFeed(日期、提要类型、节点ID)
response.contentType=“text/xml”
response.outputStream您已经解决了这个问题吗?您是否尝试过将操作从show更改为save
<g:form method="post" action="save">
而不是
<g:form method="post" action="show">
方法的名称为save。在post方法上看到“Show”操作是非常奇怪的。可能grails在幕后做了一些事情,因为grails根据约定做了很多事情,你可能都不知道!!你已经解决了这个问题吗?你尝试过将操作从Show改为save吗
<g:form method="post" action="save">
而不是
<g:form method="post" action="show">
方法名为save。看到“Show”很奇怪对post方法的操作。可能grails在幕后做了一些事情,因为grails根据惯例做了很多事情,你可能都不知道!!我想出来了,谢谢你的评论!结果是,当呈现的内容包含一个属性,例如:属性为空时,浏览器会再次请求该信息。Si由于该对象只存在于第一次调用的上下文中,第二次调用失败。换句话说,它与试图将一些XML呈现到正在呈现的页面有关。我找到了它,感谢您的评论!结果是,当呈现的内容包含一个属性时,例如:属性为空时,浏览器请求因为对象只存在于第一次调用的上下文中,所以第二次调用失败了。换句话说,它必须尝试向正在呈现的页面呈现一些XML。