spring mvc

Spring MVC介绍 Spring MVC 全名是 Spring Web MVC,简称 Spring MVC或者 Spring Web.Spring MVC 是基于Servlet API的web框架,从一开始Spring框架是包含Spring MVC部分,也就是说Spring MVC是Spring 框架的一部分。 阅读详情


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package  org.base.controller;
import  org.base.pojo.Department;
import  org.springframework.stereotype.Controller;
import  org.springframework.web.bind.annotation.RequestMapping;
import  org.springframework.web.bind.annotation.RequestParam;
@Controller
public  class  DeptController {
  /**
   * 映射的url http://localhost:端口号/项目名/test.do
   * 跳转到 (prefix)test.jsp(suffix)页面
   */
  @RequestMapping ( "/test" )
  public  String test(){
   System.out.println( "test" );
   return  "test" ;
  }
  /**
   * 如果方法无返回值,则跳转到 testP.jsp页面,即映射名
   * 对于方法中的参数,可以对应url中的参数自动赋值
   * 这里注意,如果url中的参数和方法定义的不一致,例如,此处的age=1.5,那么会报400错误
   */
  @RequestMapping ( "/testP" )
  public  void  testParam(String name,Integer age){
   System.out.println( "name:" +name+ ",age:" +age);
  }
  
  /**
   * 也可以显式声明url参数
   */
  @RequestMapping ( "/testP1" )
  public  void  testParam1( @RequestParam ( "name" )String name,Integer age){
   System.out.println( "name:" +name+ ",age:" +age);
  }
  
  /**
   * 自动注入bean属性,注意,url中形式是 departmentId=12,不是  对象.属性  形式
   */
  @RequestMapping ( "/testP2" )
  public  void  testParam2(Department dept){
   System.out.println( "dept:" +dept);
  }
/**
   * ResponseBody注解:此方法返回值直接写入 response的body中,默认是json
   * 注意要导入  jackson.jar
   */
  @RequestMapping ( "/test2" )
  @ResponseBody
  public  Department test2(){
   Department dept =  new  Department( 12 ,  "abc" ,  31 ,  5 );
   return  dept;
  } 
  //@RequestMapping 注解的方法支持很多参数: HttpServletRequest/Response,HttpSession,Writer
  // 不支持对象.属性传值方法,如果重名,/**
   * restful 风格的传参方式
   */
  @RequestMapping ( "/test3/{str}" )
 
  public  void  test3( @PathVariable ( "str" )String str){
 
   System.out.println( "str:" +str);
 
  }
 
  
 
  /**
 
   * date 日期类型的注入
 
   */
 
  @RequestMapping ( "/test4" )
 
  public  void  test4( @DateTimeFormat (iso=ISO.DATE)Date d){
 
   if (d!= null )
 
    System.out.println(
 
     new  SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(d));
 
  } 
}

@ResponseBody 可以将该方法返回的值 写入到 response的body中去(String,json,xml)。

@RequestMapping 也可以用于整个类

?
1
2
3
4
5
6
7
8
9
10
@Controller
@RequestMapping ( "/emp/*" )
public  class  EmpController {
 
  @RequestMapping ( "test1" )  // 这里匹配的url就是/emp/test1.do
  public  void  test1(String s){
 
   System.out.println( "s:" +s);
  }
}

spring 配置文件

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<? xml  version = "1.0"  encoding = "UTF-8" ?>
< beans  xmlns="
http://www.springframework.org/schema/beans
" 
   xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance
"
   xmlns:tx="
http://www.springframework.org/schema/tx
" 
   xmlns:aop="
http://www.springframework.org/schema/aop
"
   xmlns:context="
http://www.springframework.org/schema/context
" 
   xmlns:jee="
http://www.springframework.org/schema/jee
"
   xmlns:mvc="
http://www.springframework.org/schema/mvc
"
   xmlns:p="
http://www.springframework.org/schema/p
" 
   xsi:schemaLocation="
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd 
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/mvc    
http://www.springframework.org/schema/mvc/spring-mvc.xsd
">
  <!-- 加载配置文件 -->
  < context:property-placeholder  location = "classpath:config/jdbc.properties"  />
  < context:component-scan  base-package = "org.base"  />
  <!-- 开启基于注解的mvc配置 -->
  < mvc:annotation-driven >
   < mvc:message-converters >
    < bean  class = "org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" >
     <!-- 解决"IE下返回json提示下载"问题 -->
     < property  name = "supportedMediaTypes"  value = "text/plain;charset=UTF-8" ></ property >
    </ bean >
   </ mvc:message-converters >
  </ mvc:annotation-driven >
  <!-- 视图解析器 -->
  < bean  class = "org.springframework.web.servlet.view.InternalResourceViewResolver"
   p:prefix = "/WEB-INF/"  p:suffix = ".jsp" ></ bean >
</ beans >

web.xml

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<? xml  version = "1.0"  encoding = "UTF-8" ?>
< web-app  version = "2.5" 
  xmlns="
http://java.sun.com/xml/ns/javaee
" 
  xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance
" 
  xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
">
   < welcome-file-list >
     < welcome-file >index.jsp</ welcome-file >
   </ welcome-file-list >
   <!-- spring mvc -->
   < servlet >
    < servlet-name >springmvc</ servlet-name >
    < servlet-class >org.springframework.web.servlet.DispatcherServlet</ servlet-class >
    < init-param >
     < param-name >contextConfigLocation</ param-name >
     < param-value >classpath:config/spring.xml</ param-value >
    </ init-param >
    < load-on-startup >1</ load-on-startup >
   </ servlet >
   < servlet-mapping >
    < servlet-name >springmvc</ servlet-name >
    < url-pattern >*.do</ url-pattern >
   </ servlet-mapping >
</ web-app >
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package  org.base.controller;
import  org.base.pojo.Department;
import  org.springframework.stereotype.Controller;
import  org.springframework.web.bind.annotation.RequestMapping;
import  org.springframework.web.bind.annotation.RequestParam;
@Controller
public  class  DeptController {
  /**
   * 映射的url http://localhost:端口号/项目名/test.do
   * 跳转到 (prefix)test.jsp(suffix)页面
   */
  @RequestMapping ( "/test" )
  public  String test(){
   System.out.println( "test" );
   return  "test" ;
  }
  /**
   * 如果方法无返回值,则跳转到 testP.jsp页面,即映射名
   * 对于方法中的参数,可以对应url中的参数自动赋值
   * 这里注意,如果url中的参数和方法定义的不一致,例如,此处的age=1.5,那么会报400错误
   */
  @RequestMapping ( "/testP" )
  public  void  testParam(String name,Integer age){
   System.out.println( "name:" +name+ ",age:" +age);
  }
  
  /**
   * 也可以显式声明url参数
   */
  @RequestMapping ( "/testP1" )
  public  void  testParam1( @RequestParam ( "name" )String name,Integer age){
   System.out.println( "name:" +name+ ",age:" +age);
  }
  
  /**
   * 自动注入bean属性,注意,url中形式是 departmentId=12,不是  对象.属性  形式
   */
  @RequestMapping ( "/testP2" )
  public  void  testParam2(Department dept){
   System.out.println( "dept:" +dept);
  }
/**
   * ResponseBody注解:此方法返回值直接写入 response的body中,默认是json
   * 注意要导入  jackson.jar
   */
  @RequestMapping ( "/test2" )
  @ResponseBody
  public  Department test2(){
   Department dept =  new  Department( 12 ,  "abc" ,  31 ,  5 );
   return  dept;
  } 
  //@RequestMapping 注解的方法支持很多参数: HttpServletRequest/Response,HttpSession,Writer
  // 不支持对象.属性传值方法,如果重名,/**
   * restful 风格的传参方式
   */
  @RequestMapping ( "/test3/{str}" )
 
  public  void  test3( @PathVariable ( "str" )String str){
 
   System.out.println( "str:" +str);
 
  }
 
  
 
  /**
 
   * date 日期类型的注入
 
   */
 
  @RequestMapping ( "/test4" )
 
  public  void  test4( @DateTimeFormat (iso=ISO.DATE)Date d){
 
   if (d!= null )
 
    System.out.println(
 
     new  SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(d));
 
  } 
}

@ResponseBody 可以将该方法返回的值 写入到 response的body中去(String,json,xml)。

@RequestMapping 也可以用于整个类

?
1
2
3
4
5
6
7
8
9
10
@Controller
@RequestMapping ( "/emp/*" )
public  class  EmpController {
 
  @RequestMapping ( "test1" )  // 这里匹配的url就是/emp/test1.do
  public  void  test1(String s){
 
   System.out.println( "s:" +s);
  }
}

spring 配置文件

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<? xml  version = "1.0"  encoding = "UTF-8" ?>
< beans  xmlns="
http://www.springframework.org/schema/beans
" 
   xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance
"
   xmlns:tx="
http://www.springframework.org/schema/tx
" 
   xmlns:aop="
http://www.springframework.org/schema/aop
"
   xmlns:context="
http://www.springframework.org/schema/context
" 
   xmlns:jee="
http://www.springframework.org/schema/jee
"
   xmlns:mvc="
http://www.springframework.org/schema/mvc
"
   xmlns:p="
http://www.springframework.org/schema/p
" 
   xsi:schemaLocation="
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd 
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/mvc    
http://www.springframework.org/schema/mvc/spring-mvc.xsd
">
  <!-- 加载配置文件 -->
  < context:property-placeholder  location = "classpath:config/jdbc.properties"  />
  < context:component-scan  base-package = "org.base"  />
  <!-- 开启基于注解的mvc配置 -->
  < mvc:annotation-driven >
   < mvc:message-converters >
    < bean  class = "org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" >
     <!-- 解决"IE下返回json提示下载"问题 -->
     < property  name = "supportedMediaTypes"  value = "text/plain;charset=UTF-8" ></ property >
    </ bean >
   </ mvc:message-converters >
  </ mvc:annotation-driven >
  <!-- 视图解析器 -->
  < bean  class = "org.springframework.web.servlet.view.InternalResourceViewResolver"
   p:prefix = "/WEB-INF/"  p:suffix = ".jsp" ></ bean >
</ beans >

web.xml

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<? xml  version = "1.0"  encoding = "UTF-8" ?>
< web-app  version = "2.5" 
  xmlns="
http://java.sun.com/xml/ns/javaee
" 
  xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance
" 
  xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
">
   < welcome-file-list >
     < welcome-file >index.jsp</ welcome-file >
   </ welcome-file-list >
   <!-- spring mvc -->
   < servlet >
    < servlet-name >springmvc</ servlet-name >
    < servlet-class >org.springframework.web.servlet.DispatcherServlet</ servlet-class >
    < init-param >
     < param-name >contextConfigLocation</ param-name >
     < param-value >classpath:config/spring.xml</ param-value >
    </ init-param >
    < load-on-startup >1</ load-on-startup >
   </ servlet >
   < servlet-mapping >
    < servlet-name >springmvc</ servlet-name >
    < url-pattern >*.do</ url-pattern >
   </ servlet-mapping >
</ web-app >
spring mvc,spring和springboot的关系 Spring 框架是基础,提供了核心功能和模块。Spring MVC是 Spring 框架的一部分,专注于 Web 应用开发。是 Spring 框架的扩展,通过自动配置和起步依赖简化了 Spring 应用的开发。Spring 框架提供了全面的企业级应用开发功能。Spring MVC是 Spring 框架的一部分,专注于 Web 应用开发。是 Spring 框架的扩展,通过自动配置和起步依赖简化了 Spring 应用的开发。 阅读详情

相关推荐

Spring Boot、Spring MVC 和 Spring 有什么区别

Spring 是整个生态的基础,提供了最核心的 IoC 容器、AOP 等功能。Spring MVC 是基于 Spring 的 Web 框架,专门用来处理 HTTP 请求,是 Spring 的一个子模块。而 Spring Boot 是对 Spring 全家桶的封装和自动配置工具,目的是简化开发、统一约定、提升效率。Spring 是基础、Spring MVC 是扩展、Spring Boot 是加速器。

完全体 1269

Spring Boot Spring MVC

Spring MVC 是一个基于模型-视图-控制器(MVC)模式的 Web 框架,提供了一整套处理 HTTP 请求的工具,包括控制器(Controller)、视图解析(View Resolver)和模型绑定(Model Binding)。

Flying_Fish_roe的博客 2055

Spring Web MVC (Spring MVC) 的相关例题及解析

MVC、web MVC、Spring MVC 和 Spring Web MVC的联系与区别: 1.MVC 是一种架构分层模式 2.web MVC 是指在 web 领域下实践的 MVC,因为 web 领域的视图层跟 native 应用的视图层不太能划等号 3.Spring MVC 和 Spring Web MVC 是同一个东西,就是 Spring Framework 里的一个模块。在 Spring Framework 介绍页面 写的是 Spring MVC,然而点进去后具体的描述页面 使用 Spring We

努力是为了站在万人之中,成为别人的光 3万+

Spring Web MVC(Spring MVC)

4.实现服务器端代码学习Spring MVC, 其实就是学习各种Web开发需要⽤的到注解是⼀个 Web 框架.,简称之为: Spring MVCMVC 定义eg:HR就是View(视图), 负责接待候选⼈, 并告知候选⼈⾯试结果不同的部⻔, 就是Controller(控制器), HR根据候选⼈来选择对应的部⻔来进⾏⾯试⾯试官, 就是Model层, 来处理⾯试这个事情Spring MVCMVC 是⼀种架构设计模式, 也是⼀种思想, ⽽ Spring MVC。

2301_80363309的博客 1622

Zipformer实战:5分钟快速搭建语音识别模型(附LibriSpeech测试结果)

本文提供了一份详细的Zipformer语音识别模型实战指南。通过清晰的步骤,指导读者在5分钟内完成从环境配置、LibriSpeech数据集准备到模型训练与测试的全过程。文章重点解析了关键配置参数,并分享了在LibriSpeech测试集上的性能结果,帮助开发者快速评估和应用这一高效的语音识别架构。

weixin_35578748的博客 170

Verilog仿真必备:FSDB dump命令全解析与实战配置指南

本文深入解析了Verilog仿真中FSDB波形记录的核心命令与实战配置技巧。针对大规模SoC验证场景,详细介绍了如何通过$fsdbDumpvars、$fsdbDumpfile等命令实现信号精准捕获、文件体积控制和动态启停,并提供了智能化的分层dump策略,帮助工程师在保证调试信息完整性的同时,大幅提升验证效率并有效管理波形数据。

cnn8visionary的博客 354

Spring MVC

jsp 其实也是一个 Servlet,它会由容器解析成一个 Servlet,所以,使用 Model 设置的参数最终会被映射到 request 域中,jsp 从 request 中拿到要解析的值。,第一个参数传入一个 sql 语句,后面一个参数是一个函数式接口,用于将查询结果映射到 Java 类中,rs 是查询结果,rowNum 是查询的行数。<input type="button" id="queryBtn" value="查询">

hanjie13141516的博客 1482

未连接互联网的银河麒麟v10安装g++,各种报错,如何处理?

🏆本文收录于《全栈Bug调优(实战版)》专栏,主要记录项目实战过程中所遇到的Bug或因后果及提供真实有效的解决方案,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家关注&&收藏&&订阅!持续更新中,up!up!up!! 备注:部分问题/疑难杂症搜集于互联网。

**My Coding Family** 1810

Spring MVC配置

Spring MVC(Model-View-Controller)是 Spring 框架中专门处理 Web 层的模块。作为一款功能强大的 Web 框架,它遵循 MVC 模式,将应用的各个部分分离开来。具体来说,Spring MVC 是一个前端控制器(DispatcherServlet),用于接收用户请求,并根据不同的请求,分发到具体的 Controller。然 Controller 处理请求逻辑并返回数据,最后将结果交给 ViewResolver 解析为具体的视图。

m0_75260099的博客 1597

BlockUI专栏目录

BlockUI是一个设计NX对话框的工具,是官方推荐使用的对话框制作方法,能够与NX自身风格相统一,并且在实际开发中经常被使用。BlockUI可以帮助用户快速创建NX对话框,支持多种控件类型,如按钮、文本框、标签等。通过使用BlockUI,用户可以轻松地自定义对话框的布局、样式和交互行为。此外,BlockUI还提供了一些高级功能,如动态更新、条件显示和事件处理等,以帮助用户创建更加复杂和灵活的对话框。本专栏讲述了使用BlockUI制作NX对话框的方法,介绍了每个控件的功能,并且分享一些常用操作的源码。

王牌飞行员_里海的博客 1643

​非线性分析-增加位移量可能出现下面错误。虽然求解无法在所有时间点完成,但在某些点上仍能够求解部分结果。请参阅“帮助系统”中的故障排除,以了解更多信息详情。由于受约束,规划求解引擎无法收敛

基于收敛状态拆分载荷步‌:在已收敛的载荷步基础上,将未收敛的关键区域拆分为更细的子步,比如在载荷突变点前设置5~10个子步,逐步加载。替换冲突约束为弱约束‌:若存在约束冲突,将刚性约束替换为弱弹簧约束(刚度设为1e-6~1e-4),既限制刚体位移,又不影响结构的变形自由度,命令流:SPRING, NODE, K, 1e-6。部分区域约束完整,但存在未被约束的刚体自由度,或约束类型与大变形/接触逻辑冲突,比如某部件的位移约束在初始阶段有效,但大变形后约束位置脱离实际受力点,导致求解器在该阶段无法收敛。

qq_15963745的博客 168

Spring MVC—Spring MVC概述

Spring MVC

且将&的博客 705

基于YOLOv8深度学习架构的智能农业巡检小车系统—面向农作物与杂草实时精准识别的创新实践

本研究设计并实现了一套基于YOLOv8的智能农业巡检小车系统,解决农田中农作物与杂草的精准识别与追踪问题。系统采用改进YOLOv8-RGCSPELAN-ECA-AFPN模型,融合ECA注意力机制与AFPN多尺度特征融合结构,提升复杂环境下的检测精度。硬件以树莓派4B为核心,集成摄像头、传感器与电机模块,具备避障、循迹与自主导航功能。移动端基于Android部署NCNN推理引擎,实现模型高效移植与实时检测。

Stara-AI的博客 1428

Spring Web MVC

Spring Web MVC入门 和 postman使用

qq_67549203的博客 1482

C++软件异常分析概述

本文将详细讲述Windows系统中软件异常的分类以及常用的排查方法,给大家提供一个借鉴与参考。

dvlinker的技术专栏 4万+

AVDepthData、LiDAR 深度数据与人像模式全解析:iOS 真实景深图采集与处理实战

在 iOS 高端影像系统中,真实景深信息的采集与利用已成为区分旗舰设备与基础设备的重要能力。Apple 自 iPhone 7 Plus 引入双摄虚化以来,逐步发展出基于 AVDepthData、TrueDepth 与 LiDAR 的多维深度感知技术,并开放接口供开发者获取高精度深度图,构建背景虚化、人像分割、3D 重建等多种功能。本文将深入解析 AVDepthData 的结构与使用方式,系统讲解 LiDAR 采集架构、人像模式的景深融合逻辑,以及如何在实际项目中采集、预览并处理深度图数据,实现具备工程可用性

努力分享一些人工智能、计算机视觉、影像等相关的知识干货! 1866

Spring MVC 全面解析

**Spring MVC** 是 Spring 框架中的一个模块,它基于 MVC(Model-View-Controller)设计模式,旨在帮助开发者构建灵活、松耦合的 Web 应用。主要目的是简化传统 Servlet+JSP 模式下的 Web 开发方式。

技术让我们连接在一起 2028

深度学习工具包 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'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 = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```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('DeepLearnToolbox'));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('state',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'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',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 = 'sigm';%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 < 0.10, 'Too big error');```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('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';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)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';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 < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% 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'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 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<0.12, 'Too big error');```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('state',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 < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',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 < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',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 < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % 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 < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % 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 < 0.1, 'Too big error');%% 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('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % 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 < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Spring MVC 是什么?

Spring MVC 是 Spring 为表述层提供的基于 MVC 设计理念的优秀的 Web 框架,是 Spring 的一个子项目,是 JavaEE 项目表述层开发的首选方案。

JiaHao汤 1124

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

【Spring】Spring MVC 入门(2)

什么是MVC,什么是Spring Web MVC,Spring MVC 三个重点:建立连接、请求、响应。应用分层(三层架构)

m0_74164458的博客 1486

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

【JAVA】Spring MVC 详解

Spring MVC 详解

weixin_37559642的博客 2037

Spring Boot管理Spring MVC

在Spring Boot应用中使用Spring MVC时,如果希望在为Spring MVC自动配置提供相关特性的同时,再增加一些自定义的Spring MVC配置,例如添加拦截器、视图控制器等,可以通过自定义WebMvcConfigurer类型的配置类来实现。

daqi1983的博客 1648

Spring MVC 与 Spring Boot

Spring MVC 是 "工具":解决 Web 层的请求处理问题,是 Spring 生态的 Web 核心。Spring Boot 是 "加速器":基于 Spring MVC 等 Spring 组件,简化开发流程,让开发者更专注于业务逻辑而非配置。Spring Boot = Spring MVC + 自动配置 + 起步依赖 + 嵌入式服务器 + ...,它是使用 Spring MVC 的最佳实践方式。

2502_92141759的博客 761
上一篇: IP和mac地址映射关系(想找好久了)
下一篇: java序列化和反序列化
RAPIER512
博客等级 码龄12年 2粉丝 5原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值