对不起这个问题,但今天我觉得缺乏想法。我需要的是在spring mvc中实现请求确认的好方法。假设我有
@RequestMapping(params = "action=deleteitem")
public ModelAndView deleteItem(@RequestParam(value = "id") int id){
...
}
我想要一些我可以重复使用的东西,比如带有参数信息的确认页面,然后回想起这个。我可以想到100种方式,但似乎没有一种方式干净优雅。所以我想从谁那里获得比我更多的经验。
答案 0 :(得分:0)
我使用jQuery overlay并定义modalyesno
jsp标记,使用下面的内容。
删除按钮 - 在我提供的rev
属性delete action
中,将在用户确认删除时请求(点击是)。一个<t:modalyesno />
组件可能适用于许多删除按钮。
<a href="#" class="modalInput" rev="deleteitem.html?id=123" rel="#yesno" >Delete</a>
<t:modalyesno id="yesno">
Deleting item. Are You sure ?
</t:modalyesno>
modalyesno.tag:
<%@ tag description="Confirmation Dialog" pageEncoding="UTF-8"%>
<%@ attribute name="id" required="true" type="java.lang.String" %>
<!-- confirm modal dialog -->
<div class="modal" id="${id}">
<div style="text-align: center;">
<div>
<jsp:doBody/>
</div>
<div class="buttons">
<a class="close" href="#"><span>No</span></a>
<a class="close yes" href="#"><span>Yes</span></a>
</div>
</div>
</div>
jQuery的:
$(document).ready(function(){
$(".modalInput").overlay({
mask: {
color: '#aaa',
loadSpeed: 'fast',
opacity: 0.5
},
speed: 'fast',
closeOnClick: true
});
$('.modalInput').click(function(){
var modal = $(this).attr('rel');
var action = $(this).attr('rev');
/* set action on yes button */
$(modal).find('.yes').eq(0).attr('href', action);
});
});