能够掌握SSM整合的流程
能够编写SSM整合功能模块类
能够使用Result统一表现层响应结果
能够编写异常处理器进行项目异常
能够完成SSM整合前端页面发送请求实现增删改查操作
能够编写拦截器并配置拦截器
为了确保静态资源能够被访问到,需要设置静态资源过滤
xxxxxxxxxx
public class SpringMvcSupport extends WebMvcConfigurationSupport { protected void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/pages/**") .addResourceLocations("/pages/"); registry.addResourceHandler("/css/**") .addResourceLocations("/css/"); registry.addResourceHandler("/js/**") .addResourceLocations("/js/"); registry.addResourceHandler("/plugins/**") .addResourceLocations("/plugins/"); }}
xxxxxxxxxx
//列表getAll() { //发送ajax请求 axios.get("/books").then((res)=>{ this.dataList = res.data.data; });}
xxxxxxxxxx
//弹出添加窗口handleCreate() { this.dialogFormVisible = true; this.resetForm();},//重置表单resetForm() { this.formData = {};},//添加handleAdd () { //发送ajax请求 axios.post("/books",this.formData).then((res)=>{ console.log(res.data); //如果操作成功,关闭弹层,显示数据 if(res.data.code == 20011){ this.dialogFormVisible = false; this.$message.success("添加成功"); }else if(res.data.code == 20010){ this.$message.error("添加失败"); }else{ this.$message.error(res.data.msg); } }).finally(()=>{ this.getAll(); });},
xxxxxxxxxx
public class BookServiceImpl implements BookService { private BookDao bookDao; //增删改的方法判断了影响的行数是否大于0,而不是固定返回true public boolean save(Book book) { return bookDao.save(book) > 0; } //增删改的方法判断了影响的行数是否大于0,而不是固定返回true public boolean update(Book book) { return bookDao.update(book) > 0; } //增删改的方法判断了影响的行数是否大于0,而不是固定返回true public boolean delete(Integer id) { return bookDao.delete(id) > 0; } public Book getById(Integer id) { if(id < 0){ throw new BusinessException(Code.BUSINESS_ERR,"请不要使用你的技术挑战我的耐性!"); return bookDao.getById(id); } } public List<Book> getAll() { return bookDao.getAll(); }}
xxxxxxxxxx
//弹出编辑窗口handleUpdate(row) { // console.log(row); //row.id 查询条件 //查询数据,根据id查询 axios.get("/books/"+row.id).then((res)=>{ // console.log(res.data.data); if(res.data.code == 20041){ //展示弹层,加载数据 this.formData = res.data.data; this.dialogFormVisible4Edit = true; }else{ this.$message.error(res.data.msg); } });}
xxxxxxxxxx
//编辑handleEdit() { //发送ajax请求 axios.put("/books",this.formData).then((res)=>{ //如果操作成功,关闭弹层,显示数据 if(res.data.code == 20031){ this.dialogFormVisible4Edit = false; this.$message.success("修改成功"); }else if(res.data.code == 20030){ this.$message.error("修改失败"); }else{ this.$message.error(res.data.msg); } }).finally(()=>{ this.getAll(); });}
xxxxxxxxxx
// 删除handleDelete(row) { //1.弹出提示框 this.$confirm("此操作永久删除当前数据,是否继续?","提示",{ type:'info' }).then(()=>{ //2.做删除业务 axios.delete("/books/"+row.id).then((res)=>{ if(res.data.code == 20021){ this.$message.success("删除成功"); }else{ this.$message.error("删除失败"); } }).finally(()=>{ this.getAll(); }); }).catch(()=>{ //3.取消删除 this.$message.info("取消删除操作"); });}