structs2注解+jsp+ajax实现post异步加载select

2020-12-13 03:05

阅读:436

标签:异步   ajax   jsp   select   json   

流程:

1.点击加载btn发起异步请求post

2.后台处理请求返回数据

3.前端获取数据成功,对数据进行处理


前端:

html:首先要导入jq包,不然怎么用ajax呢。


后台structs:

使用注解实现,

要注意的是声明类的时候要加注解:@ParentPackage("json-default")

方法声明注解: @Action(value = "xxxx", results = @Result(name = "success", type="json"))  

需要跳转页面就把type = "json" 换成  location = "/mobile/auction_detailed.jsp" 要跳转的页面


@ParentPackage("json-default")
public class WarHouseAction extends ActionSupport {
	@Autowired
	private WarehouseService warehouseService;
	
	private List warehouses;
	
	/**
	 * 后台ajax
	 * @return
	 * 需要跳转页面就把type = "json" 换成  location = "/mobile/auction_detailed.jsp" 要跳转的页面
	 */
	@Action(value = "addGood_before", results = @Result(name = "success", type="json"))  
	public String addGoodBefore(){
		warehouses = warehouseService.findAllEnableWarehouses();   //这个是返回到页面的
		return "success";
	}

	public WarehouseService getWarehouseService() {
		return warehouseService;
	}

	public void setWarehouseService(WarehouseService warehouseService) {
		this.warehouseService = warehouseService;
	}

	public List getWarehouses() {
		return warehouses;
	}

	public void setWarehouses(List warehouses) {
		this.warehouses = warehouses;
	}
}

structs2注解+jsp+ajax实现post异步加载select,搜素材,soscw.com

structs2注解+jsp+ajax实现post异步加载select

标签:异步   ajax   jsp   select   json   

原文地址:http://blog.csdn.net/maple1320/article/details/25563893


评论


亲,登录后才可以留言!