当前位置:网站首页>_模_板_
_模_板_
2022-04-23 14:00:00 【Kramer_149】
前端
AJAX请求
$ajax({
url : "",
data : {
},
type : "",
dataType : "",
success : function(){
}
})
url 不以"/"开头,以webapp下的目录开头,比如workbench/xxx/xxx/xxx.jsp
web.xml 4.0
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
</web-app>
jsp页面字符编码、拿路径
置顶写
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";
%>
在head标签里写<base href="<%=basePath%>">
将html改成jsp之后,删除所有路径中的 ../
加了base标签之后,相对路径全部失效,必须使用绝对路径。(从webapp下开始)
后端
MySQL链接URL
语句 jdbc:mysql://localhost:3306/ssm?serverTimezone=UTC
JDK编译版本
pom文件中
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
pom 资源文件
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
MyBatis逆向工程文件
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!--指定连接数据库的JDBC 驱动包所在位置,指定到你本机的完整路径:根据具体情况修改-->
<classPathEntry location="D:\PROGRAM\MySQL\mysql-connector-java-8.0.20\mysql-connector-java-8.0.20.jar"/>
<!--配置table表信息内容体,targetRuntime 指定采用MyBatis3的版本-->
<context id="tables" targetRuntime="MyBatis3">
<!--抑制生成注释,由于生成的注释都是英文的,可以不让它生成-->
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!--配置数据库连接信息:根据具体情况修改-->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/springboot?serverTimezone=UTC" userId="root" password="123456">
<property name="nullCatalogMeansCurrent" value="true"/>
</jdbcConnection>
<!--生成model类,targetPackage指定model类的包名,targetProject指定生成的model放在哪个工程下面:根据具体情况修改-->
<javaModelGenerator targetPackage="com.daihan.springboot.model" targetProject="src/main/java">
<property name="enableSubPackages" value="false"/>
<property name="trimStrings" value="false"/>
</javaModelGenerator>
<!--生成MyBatis的Mapper.xml文件,targetPackage指定mapper.xml文件的包名,targetProject指定生成的mapper.xml放在哪个工程下面-->
<sqlMapGenerator targetPackage="com.daihan.springboot.mapper" targetProject="src/main/java">
<property name="enableSubPackages" value="false"/>
</sqlMapGenerator>
<!--生成MyBatis的Mapper接口类文件,targetPackage指定Mapper接口类的包名,targetProject指定生成的Mapper接口放在哪个工程下面-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.daihan.springboot.mapper" targetProject="src/main/java">
<property name="enableSubPackages" value="false"/>
</javaClientGenerator>
<!--数据库表名及对应的Java模型类名-->
<table tableName="t_Student" domainObjectName="Student" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
</context>
</generatorConfiguration>
把jar包导入maven中
在jar包所在目录下执行cmd
输入命令
mvn install:install-file -Dfile=jar包名称.jar -DgroupId=maven对应groupid -DartifactId=maven对应artifactId -Dversion=4.2版本号 -Dpackaging=jar
Mysql URL
mysql://localhost:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=TRUE
后端接受并处理JSON
接受参数
@RequestBody
接受请求体
@RequestHeader
接受请求头
//这里分别接受请求体为Data泛型的list,接受请求头中的id为myId
public ResponseEntity courseDataSync(@RequestBody List<Data> data,@RequestHeader("id") String myId) {
//具体Java语句
}
Data类定义
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UpstreamSyncCourseData {
private String id;
private String name;
private String description;
private String announcement = "";
//json中的course_start_time对应Data类中的courseStartTime变量
@JsonProperty(value = "course_start_time")
private Long courseStartTime;
@JsonProperty(value = "advance_days")
private Integer courseCreateTime;
}
输出JSON
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public class MyTest {
public static void main(String[] args) throws JsonProcessingException {
Phone phone = new Phone();
phone.setName("小米");
phone.setColor("红色");
phone.setPrice(2000);
ObjectMapper mapper = new ObjectMapper();
String value = mapper.writeValueAsString(phone);
System.out.println(value);
//{"name":"小米","color":"红色","price":2000}
}
}
版权声明
本文为[Kramer_149]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_46199937/article/details/118333387
边栏推荐
- UNIX final exam summary -- for direct Department
- Neuron and neural network
- How does redis solve the problems of cache avalanche, cache breakdown and cache penetration
- 1256:献给阿尔吉侬的花束
- Android篇:2019初中级Android开发社招面试解答(中
- go 语言 数组,字符串,切片
- 第十五章 软件工程新技术
- 收藏博客贴
- freeCodeCamp----arithmetic_ Arranger exercise
- Taobao released the baby prompt "your consumer protection deposit is insufficient, and the expiration protection has been started"
猜你喜欢
About note 1
SQL learning | complex query
Leetcode | 38 appearance array
Question bank and answer analysis of the 2022 simulated examination of the latest eight members of Jiangxi construction (quality control)
淘宝发布宝贝提示“您的消保保证金额度不足,已启动到期保障”
MySQL [SQL performance analysis + SQL tuning]
33 million IOPs, 39 microsecond delay, carbon footprint certification, who is serious?
Choreographer full resolution
10g database cannot be started when using large memory host
大专的我,闭关苦学 56 天,含泪拿下阿里 offer,五轮面试,六个小时灵魂拷问
随机推荐
SQL learning | complex query
Use future and countdownlatch to realize multithreading to execute multiple asynchronous tasks, and return results after all tasks are completed
淘宝发布宝贝提示“您的消保保证金额度不足,已启动到期保障”
JS 力扣刷题 102. 二叉树的层序遍历
项目中遇到的问题(五)操作Excel接口Poi的理解
Go语言 RPC通讯
Express中间件③(自定义中间件)
Taobao released the baby prompt "your consumer protection deposit is insufficient, and the expiration protection has been started"
Un modèle universel pour la construction d'un modèle d'apprentissage scikit
Oracle告警日志alert.log和跟踪trace文件中文乱码显示
Pytorch 经典卷积神经网络 LeNet
Record a strange bug: component copy after cache component jump
Android篇:2019初中级Android开发社招面试解答(中
Analysis of the problem that the cluster component GIPC in RAC environment cannot correctly identify the heartbeat network state
leetcode--977. Squares of a Sorted Array
收藏博客贴
联想产品经理林林:天津当地网络运营商网络故障 ZUI系统后台服务器暂时无法正常工作
UML统一建模语言
Haruki Murakami -- Excerpt from "what do I talk about when I talk about running"
SSM project deployed in Alibaba cloud