0
我正在写一些有关添加和编辑表单的基于Castle MonoRail的站点。添加表单工作正常,并使用POST,但编辑表单使用GET。我可以看到唯一的主要区别是编辑方法是通过在查询字符串中编辑对象的Id来调用的。当在编辑表单上按下提交按钮时,唯一传递的参数是该对象标识。下面是编辑形式的代码:单轨 - 使用GET而不是POST提交表单
<form action="edit.ashx" method="post">
<h3>Coupon Description</h3>
<textarea name="comments" width="200">$comments</textarea>
<br/><br/>
<h3>Coupon Actions</h3>
<br/>
<div>Give Stories</div>
<ul class="checklist" style="overflow:auto;height:144px;width:100%">
#foreach ($story in $stories.Values)
<li>
<label>
#set ($associated = "")
#foreach($storyId in $storyIds)
#if($story.Id == $storyId)
#set($associated = " checked='true'")
#end
#end
<input type="checkbox" name="chk_${story.Id}" id="chk_${story.Id}" value="true" class="checkbox" $associated/>
$story.Name
</label>
</li>
#end
</ul>
<br/><br/>
<div>Give Credit Amount</div>
<input type="text" name="credit" value="$credit" />
<br/><br/>
<h3>Coupon Uses</h3>
<input type="checkbox" name="multi" #if($multi) checked="true" #end /> Multi-Use Coupon?<br/><br/>
<b>OR</b>
<br/>
<br/>
Number of Uses per Coupon: <input type="text" name="uses" value="$uses" />
<br/>
<input type="submit" name="Save" />
</form>
这个和附加形式之间的差异是速度东西做与关联和输入从所述的PropertyBag作为值。
方法,采用此控制器上的处理开始是这样的:
public void Edit(int id)
{
Coupon coupon = Coupon.GetRepository(User.Site.Id).FindById(id).Value;
if(coupon == null) {
RedirectToReferrer();
return;
}
IFutureQueryOfList<Story> stories = Story.GetRepository(User.Site.Id).OnlyReturnEnabled().FindAll("Name", true);
if (Params["Save"] == null)
{
...
}
}
它可靠地被调用,但存在params [“保存”]断点让我看到,列举HTTPMethod是“GET”和只有传递的参数(在表单和请求中)是对象标识和附加的HTTP标题。
在一天结束的时候,我对MonoRail并不熟悉,这可能代表我的一个愚蠢的错误,但是我会非常感谢如果它解决了问题,我就会被愚弄掉! :)
感谢
我可以看到这段代码有一些错误的东西,但具体的问题是什么? – 2010-12-22 12:07:25