snjl

我大概率会编程。


  • 首页

  • 标签

  • 分类

  • 归档

  • 搜索

springboot:@RestController和@ResponseBody

发表于 2018-12-09 | 分类于 springboot
字数统计: 68 字 | 阅读时长 ≈ 1 分钟
  • @Controller:修饰class,用来创建处理http请求的对象
  • @RestController:Spring4之后加入的注解,原来在@Controller中返回json需要@ResponseBody来配合,如果直接用@RestController替代@Controller就不需要再配置@ResponseBody,默认返回json格式。
  • @RequestMapping:配置url映射

springboot:整合Mybatis通用Mapper插件

发表于 2018-12-09 | 分类于 springboot
字数统计: 3.3k 字 | 阅读时长 ≈ 16 分钟

项目地址:https://github.com/snjl/springboot.auto-mybatis.git

项目配置

  • Spring Boot: 1.5.9.RELEASE
  • Maven: 3.5
  • Java: 1.8
  • Thymeleaf: 3.0.7.RELEASE
  • Vue.js: v2.5.11
阅读全文 »

springboot:全局异常处理整理

发表于 2018-12-09 | 分类于 springboot
字数统计: 3.8k 字 | 阅读时长 ≈ 16 分钟

项目地址:https://github.com/snjl/springboot.auto-mybatis.git

介绍Spring Boot默认的异常处理机制

默认情况下,Spring Boot为两种情况提供了不同的响应方式。

一种是浏览器客户端请求一个不存在的页面或服务端处理发生异常时,一般情况下浏览器默认发送的请求头中Accept: text/html,所以Spring Boot默认会响应一个html文档内容,称作“Whitelabel Error Page”。

阅读全文 »

docker:简介

发表于 2018-12-07 | 分类于 服务器
字数统计: 2.1k 字 | 阅读时长 ≈ 7 分钟

参考: https://mp.weixin.qq.com/s?src=11&timestamp=1543970179&ver=1283&signature=dn5DgnKs2J2yUd7VvmKjsb-uL5RJgnl1VKGsyxX4COsRSx*igc9g42iAU5pEXQ2FLaVT1QnYRn5HsReBmIGIMdJuxOyv9y0h*cpyQXzy5rlto*QwRgGJ7vm6dmFDuhc-&new=1

http://dockone.io/article/126

维基百科:

Docker is an open-source project that automates the deployment of applications inside software containers, by providing an additional layer of abstraction and automation of operating-system-level virtualization on Linux. Docker uses the resource isolation features of the Linux kernel such as cgroups and kernel namespaces, and a union-capable filesystem such as aufs and others to allow independent “containers” to run within a single Linux instance, avoiding the overhead of starting and maintaining virtual machines.

Docker是一个开放源代码软件项目,让应用程序布署在软件容器下的工作可以自动化进行,借此在Linux操作系统上,提供一个额外的软件抽象层,以及操作系统层虚拟化的自动管理机制。Docker利用Linux核心中的资源分离机制,例如cgroups,以及Linux核心命名空间(name space),来建立独立的软件容器(containers)。这可以在单一Linux实体下运作,避免启动一个虚拟机器造成的额外负担。——摘自维基百科

阅读全文 »

matplotlib画3D图

发表于 2018-12-07 | 分类于 python
字数统计: 78 字 | 阅读时长 ≈ 1 分钟
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from matplotlib import pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = Axes3D(fig)
X = np.arange(-4, 4, 0.25)
Y = np.arange(-4, 4, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)

# 具体函数方法可用 help(function) 查看,如:help(ax.plot_surface)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='rainbow')

plt.show()

image

模式识别作业

发表于 2018-12-07 | 分类于 机器学习
字数统计: 1.1k 字 | 阅读时长 ≈ 6 分钟
  1. 以下述两类模式为样本,用感知器算法求判别函数:ω1:{(0 0 0)t,(1 0 0)t,(1 0 1)t,(1 1 0)t}; ω2:{(0 0 1)t,(0 1 1)t,(0 1 0)t,(1 1 1)t}.且令W(1)=(-1 –2 –2 0)t, C=1.

  2. 画出上题所给的二类样本,及所求的判决界面。

  3. 用LMSE算法对题1所给的两样本求判别函数 (可取C=1或C=2) 。

  4. 用势函数算法对题1所给的两样本求判别函数。

    阅读全文 »

react:设置global变量

发表于 2018-12-07 | 分类于 react
字数统计: 71 字 | 阅读时长 ≈ 1 分钟

创建一个config.js,在其他react的js文件中引入:

1
2
3
4
5
6
7
8
9
global.serverConfig = {
domainName:'http://localhost',
port:'2222',
project:'project',
};

global.server = {
host:global.serverConfig.domainName + ':' + global.serverConfig.port + '/' + global.serverConfig.project + '/',
};

即

1
global.server.host = 'httpL//localhost:2222/project/'

其他react的js文件中引入并可以直接调用:

1
2
3
import '/config'

alert(global.server.host)

react:搜索中设置回车搜索和点击搜索

发表于 2018-12-07 | 分类于 react
字数统计: 188 字 | 阅读时长 ≈ 1 分钟
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
class Com_search extends Component {
constructor () {
super();
this.state = {
code: '',
}
}

handleUsernameChange (event) {
this.setState({
code: event.target.value
});
}

triggerSearch(){
console.log(this.state.code.trim());
}
keyDownSearch(){
if(window.event.keyCode === 13) {
console.log(this.state.code.trim());
}
}


render() {
return (
<div className="search-panel">
<div className="content">
<a href='/index'><div className="logo"/></a>
<div className="search-wrap">
<input placeholder="请输入关键词" onKeyDown={this.keyDownSearch.bind(this)} defaultValue={this.state.code} onChange={this.handleUsernameChange.bind(this)} />
<div className="butn" onClick={this.triggerSearch.bind(this)} >搜索</div>
</div>
</div>
</div>
);
}
}
export default Com_search;

搜索框使用onKeyDown方法,在keyDownSearch中判断按键是否为回车,回车即调用;

点击div的搜索,即调用onClick方法,直接进行搜索。

react:form的textarea

发表于 2018-12-04 | 分类于 前端
字数统计: 53 字 | 阅读时长 ≈ 1 分钟

使用react框架的form表单,input标签填入this.state的值的时候,要用defaultValue,使用value属性会报错;

但是使用textarea,要使用value属性,使用defaultValue属性不能显示this.state的值。

springboot:测试,打包,部署

发表于 2018-12-03 | 分类于 springboot
字数统计: 1.3k 字 | 阅读时长 ≈ 5 分钟

开发阶段

单元测试

  1. 在pom包中添加spring-boot-starter-test包引用

    1
    2
    3
    4
    5
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    </dependency>
  2. 开发测试类

以最简单的helloworld为例,在测试类的类头部需要添加:@RunWith(SpringRunner.class)和@SpringBootTest注解,在测试方法的顶端添加@Test即可,最后在方法上点击右键run就可以运行。

阅读全文 »
1…141516…21
snjl

snjl

越过山丘,才发现无人等候。

203 日志
44 分类
107 标签
RSS
GitHub E-Mail Weibo
© 2019 snjl
总访问量次 | 总访客人 |
由 Hexo 强力驱动
|
主题 — NexT.Mist v5.1.4