()数据库配置
常见语句
Create table ‘my_table’(
int id not null auto_increment
)
()
建表的时候出现text,bigInt,decimal
()需要设置默认值时
用@RequestParam注解。value属性“parentId”必须跟form表单里面的name属性保持一致
@RequestParam、@RequestBody和@ModelAttribute区别可以详见下面文章
https://www.cnblogs.com/zeroingToOne/p/8992746.html
public ServerResponse addCategory(HttpSession session,String categoryName,@RequestParam(value = "parentId",defaultValue = "0") int parentId)
类开始建造
属性,构造方法,int,get方法
ServerResponse.java 文件 通用的
其中@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)—>json序列化后为null的对象,key会消失。如data为null ,都不显示
其中
@JsonIgnore
public boolean isSuccess(){
return this.status==ResponseCode.SUCCESS.getCode();
}
这句代码块的意思是返回的json中不会包含isSuccess这个方法。
package com.mmall.common;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import java.io.Serializable;
/**
* @Classname ServerResponse
* @Description TODO
* @Date 2019/2/1 21:35
* @Created by tengfei
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class ServerResponse<T> implements Serializable {
private int status;
private String msg;
private T data;
private ServerResponse(int status){
this.status=status;
}
private ServerResponse(int status,String msg){
this.status=status;
this.msg=msg;
}
private ServerResponse(int status,String msg,T data){
this.status=st