/**
* 增加
*/
public void add(TbBrand brand);
@Override
public void add(TbBrand brand) {
brandMapper.insert(brand);
}
package entity;
import java.io.Serializable;
/**
* 返回结果封装
* @author Administrator
*
*/
public class Result implements Serializable{
private boolean success;
private String message;
public Result(boolean success, String message) {
super();
this.success = success;
this.message = message;
}
//getter and setter.....
}
/**
* 增加
* @param brand
* @return
*/
@RequestMapping("/add")
public Result add(@RequestBody TbBrand brand){
try {
brandService.add(brand);
return new Result(true, "增加成功");
} catch (Exception e) {
e.printStackTrace();
return new Result(false, "增加失败");
}
}
//保存
$scope.save=function(){
$http.post('../brand/add.do',$scope.entity ).success(
function(response){
if(response.success){
//重新查询
$scope.reloadList();//重新加载
}else{
alert(response.message);
}
}
);
}
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
<h3 id="myModalLabel">品牌编辑</h3>
</div>
<div class="modal-body">
<table class="table table-bordered table-striped" width="800px">
<tr>
<td>品牌名称</td>
<td><input class="form-control" ng-model="entity.name"
placeholder="品牌名称" > </td>
</tr>
<tr>
<td>首字母</td>
<td><input class="form-control" ng-model="entity.firstChar"
placeholder="首字母"> </td>
</tr>
</table>
</div>
<div class="modal-footer">
<button class="btn btn-success" data-dismiss="modal" aria-hidden="true"
ng-click="save()">保存</button>
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">
关闭</button>
</div>
</div>
</div>
<button type="button" class="btn btn-default" title="新建" data-toggle="modal"
data-target="#editModal" ng-click="entity={}"><i class="fa fa-file-o"></i> 新建
</button>
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |