NutzCN Logo
问答 请问 web 项目中用的是HTML页面,如何请求nutz的方法呢
发布于 2427天前 作者 qq_588f5bdf 1912 次浏览 复制 上一个帖子 下一个帖子
标签:

action

@InjectName
@IocBean
@At("shipInfo")
public class ShipInfoAction extends BaseAction {
	@Inject
	private ShipInfoDao shipInfoDao;
	@Inject
	private ConsigneeInfoDao consigneeInfoDao;
	
	
	/**
	 * 寄件新增
	 * @param shipInfoAssist
	 * @return
	 */
	@At
	@Ok("json")
	public Object insertShipInfo(@Param("..") ShipInfoAssist shipInfoAssist) {
		try {
			ShipInfo shipInfo = new ShipInfo();
			shipInfo.setDdh(shipInfoAssist.getDdh());
			shipInfo.setWpmc(shipInfoAssist.getWpmc());
			shipInfo.setJjrxm(shipInfoAssist.getJjrxm());
			shipInfo.setJjrdh(shipInfoAssist.getJjrdh());
			shipInfo.setJjsj(shipInfoAssist.getJjsj());
			shipInfo.setPsjg(shipInfoAssist.getPsjg());
			
			shipInfoDao.insertShipInfo(shipInfo);
			
			ConsigneeInfo consigneeInfo = new ConsigneeInfo();
			consigneeInfo.setDdh(shipInfoAssist.getDdh());
			consigneeInfo.setSjrxm(shipInfoAssist.getSjrxm());
			consigneeInfo.setSjrdh(shipInfoAssist.getSjrdh());
			consigneeInfo.setSdrq(shipInfoAssist.getSdrq());
			consigneeInfo.setMddz(shipInfoAssist.getMddz());
			
			consigneeInfoDao.insertConsigneeInfo(consigneeInfo);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return requestResult(false, "快递单生成失败,请重新填写订单信息!!!");
		}
		return requestResult(true, "快递单已生成!!!");
	}

这样请求不生效

$.ajax({
			url : 'shipInfo/insertShipInfo.nut',
			type : 'POST',
			data : json,
			dataType : 'json',
			success : function(data) {
				if(data.success){
					mini.alert(data.data,'提醒',function(){
						CloseWindow('ok');
					});
				}else{
					mini.alert(data.data ,'提醒',function(){
						CloseWindow('ok');
					});
				}
			},
			error : function(jqXHR,textStatus,errorThrown){
				alert('访问服务器失败!!!');
			},
			complete : function(){
				
			}
		});

日志 路径似乎不对

2018-03-25 16:58:50,921 org.nutz.mvc.impl.UrlMappingImpl.get(UrlMappingImpl.java:110) DEBUG - Search mapping for [POST] path=/order/html/shipInfo/insertShipInfo : NOT Action match

2 回复

如果完全不带模板引擎或jsp的话

url : '../../shipInfo/insertShipInfo.nut'

添加回复
请先登陆
回到顶部