java SpringMVC 之 表现层与前端数据传输 SSM整合 异步处理&前后台处理联调 拦截器

【OpenClaw从入门到精通】第13篇:OpenClaw低代码编排实战:非技术人员也能玩转AI自动化流程(2026新版实测) 本文聚焦OpenClaw 2026版核心升级的低代码编排能力,针对非技术人员的实操需求,从底层逻辑、双环境部署、三类实战案例、避坑指南四个维度展开。详解阿里云集群版(企业级)与汉化本地版(个人调试)的部署步骤,通过基础数据统计、公众号内容生产线、企业级任务调度三个递进式案例,演示可视化拖拽搭建自动化流程的完整过程。全程零代码/低代码操作,配套详细参数配置、执行结果模拟及问题排查方案,帮助销售、运营、自媒体等非技术人员快速掌握自动化工具,将重复工作交给AI,提升核心工作效率。 阅读详情

SSM整合

项目结构配置搭建

pom的依赖:

 <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>4.0.1</version>
      <scope>provided</scope>
    </dependency>


    <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>5.3.18</version>
    </dependency>

    <!--    添加json数据转换相关坐标-->

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.9.0</version>
    </dependency>

    <!--   Spring 操作数据库的包-->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>6.0.0</version>
    </dependency>
    <!--mybatis包-->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version> 3.5.11</version>
    </dependency>
    <!--mybatis 与 Spring整合的包-->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>2.0.7</version>
    </dependency>
    <!--    mysql包-->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>8.0.30</version>
    </dependency>
<!--    spring 测试包  版本需要跟spring-mvc的一样-->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>5.3.18</version>
    </dependency>
    <!--德鲁伊依赖-->
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>druid</artifactId>
      <version>1.2.14</version>
    </dependency>
  </dependencies>

配置文件夹的各个配置文件:

SpringConfig:

@Configuration
@ComponentScan({"com.study.service"})
@PropertySource("classpath:jdbc.properties")
//一定要加classpath: 不然读取不到
@Import({JdbcConfig.class, MybatisConfig.class})
public class SpringConfig {

}

SpringMvcConfig

@Configuration
@ComponentScan("com.study.controller")
@EnableWebMvc
public class SpringMvcConfig {
}

JdbcConfig

public class JdbcConfig {
    @Value("${jdbc.driver}")
    private String driver;
    @Value("${jdbc.url}")
    private String url;
    @Value("${jdbc.username}")
    private String username;
    @Value("${jdbc.password}")
    private String password;

    @Bean
    public DataSource dataSource() {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName(driver);
        dataSource.setUrl(url);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        return dataSource;
    }
}

MybatisConfig

public class MybatisConfig {

    @Bean
    public SqlSessionFactoryBean sqlSessionFactory(DataSource dataSource){
        SqlSessionFactoryBean factoryBean =new SqlSessionFactoryBean();
        factoryBean.setDataSource(dataSource);
        factoryBean.setTypeAliasesPackage("com.study.domain");
        return factoryBean;
    }


    @Bean
    public MapperScannerConfigurer mapperScannerConfigurer(){
        MapperScannerConfigurer msc =new MapperScannerConfigurer();
        msc.setBasePackage("com.study.dao");
        return msc;
    }
}

ServletConfig

public class ServletConfig extends AbstractAnnotationConfigDispatcherServletInitializer {
    protected Class<?>[] getRootConfigClasses() {
        return new Class[]{SpringConfig.class};
    }

    protected Class<?>[] getServletConfigClasses() {
        return new Class[]{SpringMvcConfig.class};
    }

    protected String[] getServletMappings() {
        return new String[]{"/"};
    }
}

dao层:

public interface BrandDao {
    @Insert("insert into tb_brand1 values (null,#{brandName},#{description},#{status})")
    public void save(Brand brand);

    @Update("update tb_brand1 set brand_name=#{brandName}, description=#{description}, status=#{status} where id=#{id}")
    public void update(Brand brand);

    @Delete("delete from tb_brand1 where id =#{id}")
    //用@Results可以嵌套多个@Result
    @Results({
            @Result(property="brandName",column="brand_name")
    })
    public void delete(Integer id);

    @Select("select * from tb_brand1 where id = #{id}")
    @Results({
            @Result(property="brandName",column="brand_name")
    })
    public Brand getById(Integer id);

    @Select("select * from tb_brand1")
    public List<Brand> getAll();


}

service接口:

public interface BrandService {
    public boolean save(Brand brand);

    public boolean update(Brand brand);

    public boolean delete(Integer id);

    public Brand getById(Integer id);

    public List<Brand> getAll();
}

seivice实现类:

@Service
public class BrandServiceImpl implements BrandService {

    @Autowired
    private BrandDao brandDao;  //这里自动装配会报错,我们在设置里把检查的报错换成警告就可以了


    public boolean save(Brand brand) {
        brandDao.save(brand);
        return true;
    }

    public boolean update(Brand brand) {
        brandDao.update(brand);
        return true;
    }

    public boolean delete(Integer id) {
        brandDao.delete(id);
        return true;
    }

    public Brand getById(Integer id) {
        return brandDao.getById(id);
    }

    public List<Brand> getAll() {
        return brandDao.getAll();
    }
}

REST风格的controller类:

@RestController
@RequestMapping("/brands")
public class BrandController {
    @Autowired
    private BrandService brandService;

@PostMapping
    public boolean save(@RequestBody Brand brand) {
        brandService.save(brand);
        return true;
    }
@PutMapping
    public boolean update(@RequestBody Brand brand) {
        brandService.update(brand);
        return true;
    }
@DeleteMapping("/{id}")
    public boolean delete(@PathVariable Integer id) {
        brandService.delete(id);
        return true;
    }
@GetMapping("/{id}")
    public Brand getById(@PathVariable Integer id) {
        return brandService.getById(id);
    }
@GetMapping
    public List<Brand> getAll() {
        return brandService.getAll();
    }
}

测试

注意:测试的spring-test版本需要跟spring-webmvc版本一致,否则会报错

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SpringConfig.class)
public class BrandServiceTest {

    @Autowired
    private BrandService brandService;

    @Test
    public void testGetById(){
        Brand brand = brandService.getById(1);
        System.out.println(brand);
    }

    @Test
    public void testGetAll(){
        List<Brand> all =brandService.getAll();
        System.out.println(all);
    }
    
}

增删改查的内容,我们直接用tomcat运行然后postman进行调试就可以了

事务

1.首先在JdbcConfig里面编写事务管理的bean类

2.在SpringConfig加上 @EnableTransactionManagement //注解开发事务

3.在对应的接口上加上@Transactional

表现层数据封装

我们后台返回的类型有很多,这时候我们封装成一个Result类,这样就统一起来,并且方便跟前端交互,封装的时候要记得设置相应的构造方法 这样会更方便

 然后我们再封装一个Code类,使用静态常量定义各个状态,这样我们就能通过类名.常量名调用了

Controller把所有返回值都设置成Result的结果:

@RestController
@RequestMapping("/brands")
public class BrandController {
    @Autowired
    private BrandService brandService;

    @PostMapping
    public Result save(@RequestBody Brand brand) {
        boolean flag = brandService.save(brand);
        return new Result(flag ? Code.SAVE_OK:Code.SAVE_ERR,flag);
    }

    @PutMapping
    public Result update(@RequestBody Brand brand) {
        boolean flag = brandService.update(brand);
        return new Result(flag ? Code.UPDATE_OK:Code.UPDATE_ERR,flag);
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        boolean flag = brandService.delete(id);
        return new Result(flag ? Code.DELETE_OK:Code.DELETE_ERR,flag);
    }

    @GetMapping("/{id}")
    public Result getById(@PathVariable Integer id) {
        Brand brand = brandService.getById(id);
        Integer code =brand!=null?Code.GET_OK:Code.GET_ERR;
        String msg =brand!=null?"":"数据查询失败,请重试";

        return new Result(code,brand,msg);
    }

    @GetMapping
    public Result getAll() {
        List<Brand> all = brandService.getAll();
        Integer code =all!=null?Code.GET_OK:Code.GET_ERR;
        String msg =all!=null?"":"数据查询失败,请重试";
        return new Result(code,all,msg);
    }
}

异常处理器

 异常出现的地方会很多,最好就是集中在表现层进行处理

SpringMVC就提供了异常处理器

我们在Controller包里新建一个异常处理器

 项目异常处理方案

 

我们创建一个exception包

然后在里面分别自定义各个种类的异常类BusinessException 跟 SystemException

继承RuntimeException,并加一个code变量,分别写上构造方法。如:

public class SystemException extends RuntimeException{
    private Integer code;


    public SystemException( Integer code,String message) {
        super(message);
        this.code = code;
    }

    public SystemException(String message,Throwable cause, Integer code) {
        super(message,cause);

        this.code = code;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
}

 

触发后我们修改之前在controller层写的ProjectExceptionAdvice,分别拦截各种异常并作出相应的处理

 前端页面放行

为了避免,前端的页面已经js css之类的被SpringMVC拦截,我们新建一个SpringMvcSupport类

然后在SpringMvcConfig中把对应的包位置扫进去,就可以了

@ComponentScan({"com.study.controller","com.study.config"})

前端代码:

<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>SpringMVC案例</title>
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
</head>

<body class="hold-transition">

<div id="app">
    <div class="content-header">
        <h1>品牌管理呵呵</h1>
    </div>
    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <el-input placeholder="品牌名称" v-model="pagination.queryString" style="width: 200px;"
                          class="filter-item"></el-input>
                <el-button @click="getAll()" class="dalfBut">查询</el-button>
                <el-button type="primary" class="butT" @click="handleCreate()">新建</el-button>
            </div>

            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                <el-table-column type="index" align="center" label="序号"></el-table-column>
                <el-table-column prop="brandName" label="品牌名称" align="center"></el-table-column>
                <el-table-column prop="description" label="品牌描述" align="center"></el-table-column>
                <el-table-column prop="status" label="品牌状态" align="center"></el-table-column>
                <el-table-column label="操作" align="center">
                    <template slot-scope="scope">
                        <el-button type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>
                        <el-button type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <!-- 新增标签弹层 -->

            <div class="add-form">
                <el-dialog title="新增图书" :visible.sync="dialogFormVisible">
                    <el-form ref="dataAddForm" :model="formData" :rules="rules" label-position="right"
                             label-width="100px">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="品牌名称" prop="brandName">
                                    <el-input v-model="formData.brandName"/>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="品牌描述" prop="description">
                                    <el-input v-model="formData.description"/>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="24">
                                <el-form-item label="状态">
                                    <el-input v-model="formData.status" type="textarea"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>

                    <div slot="footer" class="dialog-footer">

                        <el-button @click="dialogFormVisible = false">取消</el-button>

                        <el-button type="primary" @click="handleAdd()">确定</el-button>

                    </div>

                </el-dialog>

            </div>

            <!-- 编辑标签弹层 -->

            <div class="add-form">
                <el-dialog title="编辑检查项" :visible.sync="dialogFormVisible4Edit">
                    <el-form ref="dataEditForm" :model="formData" :rules="rules" label-position="right"
                             label-width="100px">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="品牌名称" prop="brandName">
                                    <el-input v-model="formData.brandName"/>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="品牌描述" prop="description">
                                    <el-input v-model="formData.description"/>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="24">
                                <el-form-item label="品牌状态">
                                    <el-input v-model="formData.status" type="textarea"></el-input>
                                </el-form-item>
                            </el-col>

                        </el-row>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible4Edit = false">取消</el-button>
                        <el-button type="primary" @click="handleEdit()">确定</el-button>
                    </div>
                </el-dialog>
            </div>
        </div>
    </div>
</div>

</body>

<!-- 引入组件库 -->

<script src="../js/vue.js"></script>

<script src="../plugins/elementui/index.js"></script>

<script type="text/javascript" src="../js/jquery.min.js"></script>

<script src="../js/axios-0.18.0.js"></script>

<script>
    var vue = new Vue({

        el: '#app',
        data: {
            pagination: {},
            dataList: [],//当前页要展示的列表数据
            formData: {},//表单数据
            dialogFormVisible: false,//控制表单是否可见
            dialogFormVisible4Edit: false,//编辑表单是否可见
            rules: {//校验规则
                brandName: [{required: true, message: '图书类别为必填项', trigger: 'blur'}],
                description: [{required: true, message: '图书名称为必填项', trigger: 'blur'}]
            }
        },

        //钩子函数,VUE对象初始化完成后自动执行
        created() {
            this.getAll();
        },

        methods: {
            //列表
            getAll() {
                //发送ajax请求
                axios.get("/brands").then((res)=>{
                    this.dataList=res.data.data;
                });
            },

            //弹出添加窗口
            handleCreate() {
                this.dialogFormVisible=true;
                this.resetForm();
            },

            //重置表单
            resetForm() {
                this.formData={}
            },

            //添加
            handleAdd() {
                //发送ajax请求
                axios.post("/brands",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();
                })
            },

            //弹出编辑窗口
            handleUpdate(row) {
                //弹出窗口要根据id查询数据
                axios.get("/brands/"+row.id).then((res)=>{

                    if(res.data.code===20041){
                        //查询成功则弹出编辑页面
                        this.formData=res.data.data;
                        this.dialogFormVisible4Edit=true;
                    }else {
                        this.$message.error(res.data.msg)
                    }

                })
            },

            //编辑
            handleEdit() {
                axios.put("/brands",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();
                })
            },

            // 删除
            handleDelete(row) {
                //弹出提示框
                this.$confirm("此操作将永久删除当前数据,是否继续?","提示",{
                    type:'info'
                }).then(()=>{ //点击确定后执行下面代码
                    axios.delete("/brands/"+row.id).then((res)=>{

                        if(res.data.code===20021){
                            //查询成功则弹出编辑页面
                            this.$message.success("删除成功")
                            this.getAll();
                        }else {
                            this.$message.error("删除失败")
                        }

                    }).catch(()=>{
                        //取消删除
                    })
                })
            }
        }
    })

</script>

</html>

拦截器

拦截器(Interceptor)是一种动态拦截方法调用的机制,在SpringMVC中动态拦截控制器方法的执行 

作用:

在指定的方法调用前后执行预先设定的代码

阻止原始方法的执行

 

 我们在Controller包中 新建一个interceptor包,在包中新建如上所示ProjectInterceptor类

然后在之前写的SpringMvcSupport中添加刚才我们自定义的拦截器并设置拦截的路径:

 拦截路径可以为多个,也可以用星号*, addPathPatterns("/books", "/books/*");、

当然我们也可以简化开发:也就是在SpringConfig直接实现WebMvcConfig但是侵入性比较强

 当返回值为false则直接不运行后面的方法,直接结束

 拦截器参数

 

 

多拦截器执行顺序

书写格式:

 

 

 

 

搞定最强大模型Gemini学生订阅,白嫖一年,包教包会 白嫖现在最强大模型 阅读详情

相关推荐

用SPSS做信效度分析

对问卷进行Cronbach’s Alpha信度检验。如果此值高于0.8,则说明信度高;如果此值介于0.7-0.8之间,则说明信度较好;如果此值介于0.6~0.7,则说明信度可接受;如果此值小于0.6,说明信度不佳。下面利用SPSS进行分析,点击分析–标度–可靠性分析选项,选中所要分析的问卷数据或题目。得到结果,我们要看这个有用的结果,当克隆巴赫Alpha系数(也可以看标准化后的)大于0.8时候,说明问卷信度较高。

小高~的博客 1万+

SSM框架学习-请求映射路径、请求参数、json数据传送参数以及日期型参数传递

ssm笔记

qq_45681515的博客 896

用Python爬取公众号历史所有文章,看这篇就够了

手把手教你爬取公众号历史所有文章

u010522887的专栏 1万+

SSM框架中使用ajax传递数据

1. 依赖准备 &lt;dependency&gt; &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt; &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt; &lt;version&gt;2.13.0&lt;/version&gt; &lt;/dependency&gt; &lt;

SSL 的博客 2408

SICK LMS111激光雷达数据解析实战:从原始帧到三维点云的完整流程

本文详细解析了SICK LMS111激光雷达从原始数据帧到三维点云的完整处理流程,包括数据帧结构解析、坐标转换、点云可视化及性能优化技巧。通过实战代码示例,展示了如何高效处理激光雷达数据,并应用于动态物体检测、地面分割等工业场景,为AGV和服务机器人开发者提供实用指南。

garlic的博客 773

读书笔记:深度学习入门-基于python的理论与实现(俗称鱼书)

终于从头到尾把鱼书看完啦,真的是非常入门,非常查漏补缺,对新手很友好,对有一定基础的人也非常不错。看完不复习等于没看,所以今天开始复盘,顺便写这篇读书笔记。希望分享给没看过这本书或者看过这本书的同僚们参考,欢迎大家指教。我将从第三章神经网络开始复习,前两章内容书里已经非常基础and清楚了。(会持续更新滴).........

博客而已 1万+

SSM框架流程分析

SSM框架流程分析

m0_58181298的博客 432

AI Agent技能评测框架SkillsBench:从黑盒评估到白盒技能拆解

在人工智能领域,模型评估是衡量技术进展的核心环节。传统评测基准如GLUE、MMLU主要关注模型的通用认知能力,但实际工程应用中,AI Agent需要的是在复杂场景中协调多种能力的“职业技能”。SkillsBench创新性地将Agent能力进行原子化拆解,定义了理解规划、工具调用、推理决策、交互安全等技能维度,并通过领域专家构建的评测集确保生态效度。这一框架为Agent开发提供了精准的“度量衡”,使性能优化从经验驱动转向数据驱动,同时为不同模型和框架提供了公平比较的基础,推动了AI Agent生态从“野蛮生长

weixin_30530339的博客 395

SSM框架中,后台向前端传送数据的方法

SSM框架中,后台向前端传送数据的方法 在SSM框架中我们会根据前端传递过来的数据进行业务操作,在操作之后会把结果数据返回给前端页面,前端页面才会展示给客户观看,那么后台如何向前端返回数据的呢? 我们在Controller层的Action类中编写的方法返回值通常会有三种:ModelAndView、String、Void;通常在项目中使用时,若不使用ajax传递数据,则选择使用String返回值;如...

sjl362255732的博客 1万+

从收音机到Arduino:手把手教你用BJT三极管搭建一个简易音频放大器(附电路图与元件清单)

本文详细介绍了如何使用BJT三极管搭建简易音频放大器,涵盖电路原理、元件选择、设计步骤及调试技巧。通过实践项目帮助电子爱好者深入理解BJT的放大特性,并提供与Arduino结合的扩展应用方案,适合创客和DIY玩家。

aitie1479的博客 451

SIMPLIS实战:从零构建理想BUCK电路,精准计算与POP稳态分析

本文详细介绍了如何使用SIMPLIS软件从零开始构建并仿真一个理想的BUCK降压电路。通过设定关键参数、计算理想器件值,并搭建仿真模型,文章重点演示了暂态仿真以观察电路上电过程,并深入讲解了高效的POP(周期性工作点)稳态分析技术,帮助工程师快速验证设计、评估稳态性能,从而加速电源设计迭代。

weixin_29165465的博客 404

ssm提交post_使用java ssm框架后台模拟post上传文件并提交表单数据

环境 jdk1.8 ide:eclipse 框架:spring 4.3.4 mybatis3.3.4利用纯java后台实现post提交数据并上传文件模拟post部分/**** @description 模拟post提交* @version 1.0* @author 张尧* @update 2017年7月7日 上午9:19:07*/public static void uploads(){Strin...

weixin_35319943的博客 504

【软碟通 | UltraISO】刻录光盘教程(制作U盘启动盘)

前言 今天老师说办公室的电脑有点卡,让我给重新安装一个 Windows 7 系统。于是就用软碟通(UltraISO)在 U 盘上刻录了一个 Windows 7 镜像,然后给老师重装了系统。顺便把制作 U 盘启动盘的教程也分享给大家。 软件 UltraISO v9.7.1.3519:点击跳转(密码:dd2k) 教程 将 U 盘插到电脑上,然后鼠标右击选择格式化(制作启动盘必须格式化) 点击文件-打开 选择下载好的系统镜像(如:Windows 7) 点击启动-写入硬盘映像 选择硬盘

XavierJ的博客 2万+

SpringMVC-Day2

20031 -> 增删改20041 -> 查询。

2301_78630849的博客 975

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = &quot;R. B. Palm&quot;, title = &quot;Prediction as a candidate for learning deep hierarchical models of data&quot;, year = &quot;2012&quot;,}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er &lt; 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er &lt; 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er&lt;0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er &lt; 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er &lt; 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er &lt; 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er &lt; 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er &lt; 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er &lt; 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free &quot;Bitdeli Badge&quot;)

全网最强SpringMVC教程 | 万字长文爆肝SpringMVC(二)

SSM框架整合开发与核心功能实现 摘要:本文档详细介绍了Spring、SpringMVC和MyBatis(SSM)三大框架的整合开发流程,包括统一结果封装、异常处理、前后端功能整合以及拦截器实现。主要内容涵盖: SSM整合配置: 创建Maven web工程并添加依赖 配置Spring核心类(SpringConfig)和数据源(JdbcConfig) 配置MyBatis整合(MybatisConfig) 配置SpringMVC(SpringMvcConfig) 核心开发流程: 基于三层架构(DAO、Servi

qq_45832461的博客 1121

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

SSM+Vue健康医疗预约系统:从选型到答辩完整指南

前后端分离架构已成为现代Web开发的普遍范式,其中后端聚焦业务逻辑与数据持久化,前端专注交互体验与界面呈现。SSM框架(Spring+SpringMVC+MyBatis)作为Java服务端经典组合,凭借轻量灵活和生态成熟,至今仍被大量企业级项目采用;Vue.js则以渐进式的设计理念和组件化开发体验,成为构建单页应用的高效选择。二者结合的技术价值在于:后端通过Spring容器管理Bean、MyBatis映射SQL,前端借助Vue响应式数据绑定和路由机制,有效降低系统耦合度并提升开发效率。在医疗数字化转型背景下

weixin_34026997的博客 283

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

Spring Boot商城系统毕业设计:从架构设计到防超卖实战全解析

在电商系统开发中,高并发下的数据一致性与缓存设计始终是核心挑战。基于Spring Boot的主流技术栈,能够将复杂的业务模块化、分层化,既保证了系统的可扩展性,也降低了工程落地的门槛。通过Redis实现热点数据缓存与分布式协调,配合数据库乐观锁或预扣减机制有效防止库存超卖,同时利用JWT完成无状态认证,这些技术组合已成为现代商城系统的基础范式。从商品浏览、购物车到订单履约,再到支付仿真与后台管理,每一环节都蕴含着状态机设计、事务边界控制等工程实践。对于计算机毕业设计而言,商城系统不仅需求明确、模块垂直,更能

weixin_34214500的博客 393

Java秋招八股之王——拿不到大厂Offer来找我(全文14w字,持续更新)

如果你需要一套八股文,想要一套八股文解决秋招的大部分问题,来看看这篇文章吧~内容包含数据结构、计算机网络、数据库、Redis、消息队列、JavaSE、JVM、JUC、海量数据题目、高并发场景、项目的亮点难点、ssm框架、dubbo框架等等。这是我整个秋招不停面试的总结和反思,最后也是靠它拿到了菜鸟的offer,希望会对后面秋招的朋友起到一些帮助。

qq_40460454的博客 1297

SpringBoot+Vue前后端分离的机动车号牌管理系统设计与实现

在交通管理数字化进程中,机动车号牌信息的规范化管理成为提升车辆登记与调度效率的关键环节。Web应用系统常采用前后端分离架构,通过RESTful API解耦业务逻辑与界面渲染,SpringBoot作为后端框架提供自动配置与快速部署能力,Vue以组件化方式构建交互友好的管理界面,MySQL则负责存储车主、车辆与号牌等核心业务数据。该技术组合成熟稳定、生态完善,被广泛应用于企业级信息管理系统开发。基于这一主流技术栈,可高效实现号牌申领、状态跟踪、权限控制及可视化统计等业务功能,既满足交通管理部门的信息化需求,也为

weixin_34192816的博客 182

mybatis 传递参数的7种方法

mybatis 传递参数的7种方法 在实际开发过程中,增删改查操作都要涉及到请求参数的传递,今天这节就集中讲下在mybatis中传递参数的7中方法 单个参数的传递很简单没有什么好将的,这里主要说下多个参数的传递 1.第一种方式 匿名参数 顺序传递参数 controller @ApiOperation(value = "多个参数查询_匿名顺序传参") @GetMapping("findByPara...

独钓寒江雪 6万+

SSM开发笔记4-2前后端信息传递及结果信息处理

一、前端信息传递(JS) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1、定义对象 var shop = {} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2、给对象添加值 shop.shopName = $("#shopName").val();赋值 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb...

Kasey_L的博客 632

SSM框架学习——界面输入数据保存到数据库

SSM框架学习——界面输入数据保存到数据库 一、分析Springmvc的请求流程 1、什么是请求? &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;在浏览器地址栏中输入网址,然后回车就表示请求。 2、什么是响应? &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;在请求后,浏览器中显示的内容就是响应。 (https://imgchr.com/i/r7OMKs) 3、请求流程分析 第一步:输入网址,发出请求 第二步:请求到达被请求的项目,任何请求到达被请求的项目后

qq_44887353的博客 4449

ssm前后端数据传输

前后端传输数据的几种方式

qq_42392371的博客 352

SSM框架--前后端数据传输逻辑整理

由于代码的学习一直都是根据视频课以及有相关工作经验的朋友学习,所以自己思考的还是很不足。学习了很长时间碎片化的项目,也写过一些小的项目,但是这之间的逻辑依然没有吃透。尝试总结一下SSM框架下前后端数据传输的实现,也是对这段时间框架学习的小总结。 文章目录前言一、SSM框架实现思路二、实现步骤1.前端部分的页面请求2.根据spring_mvc.xml配置文件,去寻找相应的controller3.在表现层找到了相应的 PatientController.java4.表现层controller去向业务层serv

然小梨的博客 6298

SSM中前后台数据的流动和获取

开始 前台:jsp,js,ajax 后台:controller controller接收前台数据 普通方式-请求参数名和Controller方法的参数名字一致 对象方式-请求参数名和Controller方法中参数对象的属性名字一致 自定义方法参数名-当请求参数名与方法参数名不一致时 @RequestParam(“前端参数名”) 后台方法参数名 HttpServletRequest方式 request.getParameter(“前端参数名”); @PathVariable获取路径中的参数接收 @Reque

m0_46692607的博客 1710

ssm配置 异步线程池

Spring配置异步任务处理 2018年07月13日 00:50:20 如不來 阅读数 131 前言: 在项目开发中,我们经常会有异步调用任务的需求,比如: a.在与第三方系统数据交互时,需要另开一个线程去执行交互任务 b.系统中日志记录不希望引起响应迟缓 c.短信、发送邮件等 web.xml 3.0才开始支持异步,Spring3.2以上版本中提供了@async注解帮...

qq_41524941的博客 2578
上一篇: JAVA之Spring MVC 请求与响应 postman简介 REST风格
下一篇: SpringBoot 简介 基础配置 yaml 多环境开发配置 整合第三方技术 springboot整合
M00SE
博客等级 码龄4年 93粉丝 123原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值