1. spring mvc post请求参数接收的方法

1.使用@RequestParam String username接收,这种方式使用的是form表单形式,或者直接使用直接使用User user接收;
2.使用@RequestBody UserForm userForm形式接收,这种方式使用的是application/json方式接收。这种方式的好处是,可以把所需要的参数单独封装起来,封装在form包下,同时可以配合使用javax.validation进行表单校验。

  1. mybatis-generator的基础模板配置
<?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>
    <classPathEntry location="E:\mysql-connector-java-5.1.6.jar" />
    <!--<classPathEntry location="src/main/resources/application.yml" />-->
    <context id="DB2Tables" targetRuntime="MyBatis3">
        <!--不再追加xml-->
        <plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin"></plugin>
        <commentGenerator>
            <property name="suppressAllComments" value="true"></property>
        </commentGenerator>
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                        connectionURL="jdbc:mysql://localhost:3306/mall?characterEncoding=utf-8"
                        userId="root"
                        password="123456">
        </jdbcConnection>
        <javaTypeResolver >
            <property name="forceBigDecimals" value="false" />
        </javaTypeResolver>

        <javaModelGenerator targetPackage="com.imooc.mall.pojo" targetProject="src/main/java">
            <property name="enableSubPackages" value="true" />
            <!--<property name="trimStrings" value="true" />-->
        </javaModelGenerator>

        <sqlMapGenerator targetPackage="mapper"  targetProject="src/main/resources/">
            <property name="enableSubPackages" value="true" />
        </sqlMapGenerator>

        <javaClientGenerator type="XMLMAPPER" targetPackage="com.imooc.mall.dao"  targetProject="src/main/java">
            <property name="enableSubPackages" value="true" />
        </javaClientGenerator>

        <!--<table tableName="mall_order" domainObjectName="Order"-->
               <!--enableCountByExample="false"-->
               <!--enableDeleteByExample="false"-->
               <!--enableSelectByExample="false"-->
               <!--enableUpdateByExample="false">-->
        <!--</table>-->

        <!--<table tableName="mall_order_item" domainObjectName="OrderItem"-->
               <!--enableCountByExample="false"-->
               <!--enableDeleteByExample="false"-->
               <!--enableSelectByExample="false"-->
               <!--enableUpdateByExample="false">-->
        <!--</table>-->

        <table tableName="mall_user" domainObjectName="User"
               enableCountByExample="false"
               enableDeleteByExample="false"
               enableSelectByExample="false"
               enableUpdateByExample="false">
        </table>

    </context>
    <!--mvn mybatis-generator:generate-->
</generatorConfiguration>

其他配置可以参加:https://www.jianshu.com/p/e09d2370b796

  1. 所有的常量不要使用硬编码,全部使用枚举或者常量方法;