Atitit code 范例 example code 范例 example 更好一些,将最佳实践融入其中。。目录第一章 Springboot 1第二章 Rest api 1第一节
Atitit code 范例 example
code 范例 example 更好一些,将最佳实践融入其中。。
目录
第一节 Atitit http rest php workman api rsps
第二节 Atitit recv https req post code 接受https请求 nodejs
第四节 Db acc code mybatis jsdbtmeplte hbnt
第四节 Nodejs https http post json
第一节 ExcelUtil export json list
Springboot test,,springboot lazy load
/miniCodePrj/src/main/java/sprbtPKg/Application.java
Php rest api
public static void main(String[] args) {
// sqlSessionFactory=getSqlSessFctry(dataSource, UserMapper.class);
// tk_ini(sqlSessionFactory);
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/mysql?allowMultiQueries=true"; // 创建一个表示数据库路径的字符串
String username = "root"; // 创建一个表示数据库用户名的字符串
String password = ""; // 创建一个表示数据库密码的字符串
DriverManagerDataSource dataSource = new DriverManagerDataSource(url, username, password);
String tableName = "user";
Map<String, Object> parameters_map = new HashMap<String, Object>(3);
parameters_map.put("id", 123);
parameters_map.put("first_name", "aaa");
int i = insert(dataSource, tableName, parameters_map);
System.out.println(i);
System.out.println("f");
}
private static int insert(DriverManagerDataSource dataSource, String tableName,
Map<String, Object> parameters_map) {
SimpleJdbcInsert SimpleJdbcInsert1 = new SimpleJdbcInsert(dataSource).withTableName(tableName);
Set st = parameters_map.keySet();
List<String> columnNames = new ArrayList<String>();
columnNames.addAll(st);
SimpleJdbcInsert1.setColumnNames(columnNames);
// SimpleJdbcInsert1.usingColumns(columnNames)
int i = SimpleJdbcInsert1.execute(parameters_map);
return i;
}
Hibernate code demo
MybatisTest
String uri=rq.getRequestURI();
String query=rq.getQueryString();
String newUrl = targetHost+uri+"?"+query;
CloseableHttpResponse response =HttpClients.createDefault().execute(new HttpGet(newUrl)) ;
return EntityUtils.toString(response.getEntity(), "UTF-8");
Atitit php http post jspn code
Nodejs.http post json
const args = process.argv.slice(2)
//var param=args[0];
var param = (new Buffer(args[0], 'base64').toString())
//var param={};
var fs = require('fs');
var cfgObj = JSON.parse(fs.readFileSync('a_cfg.json') + '');
console.log(cfgObj)
var $url = cfgObj['url'];
//"https://7398c09d63b0.ngrok.io/v1/api/order/build";
console.log($url);
console.log(param);
var prmObj = JSON.parse(param);
const axios = require('axios')
//zwajye cyifen json hesh txt...zosh yaosi obj shg json ,zo head add app/json,,beir txt ..
axios
.post($url, prmObj)
.then(res => {
// console.log(`statusCode: ${res.statusCode}`) //statusCode: undefined
console.log(res.data);
// console.log(res)
})
.catch(error => {
console.error(error)
})
Atitit 读取文件并处理
Ticyiutxt.php
<?php
$f="d:\\ppl";
$con = file($f );
$data = array();
foreach($con as $line) {
$posStart=stripos($line, "——");
if($posStart){
// $line = trim($line);
$name= substr($line, $posStart);
echo $name;
}else
{
echo $line;
}
}
Ref
Atitit mybatis helloworld
相关文章
- 补习系列(14)-springboot redis 整合-数据读写
- SpringBoot整合SpringMVC、持久层技术MyBatis、连接mysql数据库技术
- springboot 通过 hibernate 连接sqlserver 空间数据 位置数据
- 【FastDFS】SpringBoot整合FastDFS实战,我只看这一篇!!
- Springboot构建Echarts数据可视化
- SpringBoot----嵌入式Servelt容器
- Kotlin — Springboot 与 Kotlin构建Web应用程序
- SpringBoot整合MyBatisPlus
- SpringBoot利用外部配置,来设置jar包运行配置
- springboot使用jxls导出excel___(万能通用模板)--- SpringBoot导入、导出Excel文件___SpringBoot整合EasyExcel模板导出Excel