$('#location').on('click',function(){
layer.open({//调用layer弹出层
type: 2,
title: '地图位置',
scrollbar: false,
maxmin: false,
shadeClose: false, //点击遮罩关闭层
area : ['1000px' , '500px'],
content: '${ctx}/office.action?method:getLocation&office.id=${ office.id }&pageNo=${ param.pageNo }&pageSize=${ param.pageSize }&conditionStr=${ conditionStrEncoded}'
});
});
'${ctx}/office.action?method:getLocation&office.id=${ office.id }&pageNo=${ param.pageNo }&pageSize=${ param.pageSize }&conditionStr=${ conditionStrEncoded}'
通过这种方法来传递到指定的getLocation方法,并且传过去office.id、pageNo、pageSize、conditionStr等参数值,不然会出现错误。
2,
public String getLocation(){
return "office_map";
}
通过getLocation的return "office_map"到对应的result的jsp文件。
@ParentPackage(value="erp")
@Results({
@Result(name="list", location="/erp/office/office_list.jsp"),
@Result(name="editForm", location="/erp/office/office_edit_form.jsp"),
@Result(name="office_map", location="/erp/office/office_map.jsp"),
})
3,
<input type="hidden" name="office.longitude" id="office_longitude" value="${ office.longitude}"/>
<input type="hidden" name="office.latitude" id="office_latitude" value="${ office.latitude}"/>
<button type="submit" id="confirm" class="btn btn-sm btn-primary savaBtn" name="method:editFormTo">确认</button>
跳转到editFormTo方法中
public String editFormTo(){
Double lon = (Double) getParameter( "office.longitude", Double.class);
Double lat = (Double) getParameter( "office.latitude", Double.class);通过getParameter拿到jsp文件中的name属性名对应的值。
String address=(String)getParameter("office.address", String.class);
String sql = "from Office where id ="+office.getId()+"";
offices = manager.find(sql);
office = offices.get(0);
if(lon>0){
office.setLongitude(lon);
}
if(lat>0){
office.setLatitude(lat);
}
office.setAddress(address);
对其进行赋值。
return EDITFORM;
}
重要的一个事情,就是值的传递。。可以通过url的方式& 传递值,
或者通过request的getParameter方法拿到对应的name属性对应的值。byName。
而定义的
<input type="hidden" name="office.longitude" id="office_longitude" value="${ office.longitude}"/>
在jsp中通过document.getElementById来拿到。
var latitude = document.getElementById("office_latitude").value;
在对应的调用的action的方法中通过Double lon=(Double)getParameter("office.longitude",Double.class);来拿到