1.mybatis中入参是map
最常使用的不是parameterMap,是使用parameterType
2.mybatis映射文件中的parameterType:
3.配置mvc拦截器之后,要是在mvc配置文件中释放静态资源,否则无法正常加载图片和样式
<mvc:default-servlet-handler></mvc:default-servlet-handler>
4.restful风格,接收不同参数 需要用到的注解
put和post :@requestbody 接受前端发送的json串
get和delete :不能发送json串 不用@requestbody
1.参数跟在地址栏后 get/{id}: @PathVariable("id") String id
2.用对象接受参数: @RequestBody User user
3.使用map接收参数: @RequestBody Map map
4.@deletemapper 接受数组 @RequestParam String[] ids
5.get请求字符串拼接在地址后 直接用同名参数接受
5..delete请求无法使用data
解决方法1:
可以直接将参数拼接在请求地址中,如果是传递数组,可以先进行循环拼接,然后传递数据
var activityIds=$("#relate-activity input[type='checkbox']:checked")//先拿到所有选中的id
$.each(activityIds,function(){
ids+="activityId="+this.value+"&" //获取value进行拼接
})
url:"workbench/clue/relateActivity.do?id="+ids
解决方法2:
将ajax的type设置为post, 然后data{}中添加一个参数 _method:'delete'
这样就可以在请求体当中提交data
5.ajax中提交data为json字符串(data:JSON.stringify({}))
必须设置参数contentType: 'application/json'
6.@Autowried @Resource
都是进行自动装配bean的 auto根据类型byType resource根据名称(默认)和类型
byType: @Autowried @Resource
UserMapper u; UserMapper u;
ByName: @Autowried @Resource(name="userMapper")
@qualifier("userMapper") UserMapper u;
UserMapper u;
7.部署到linux中遇到的一些异常
(1)javax.net.ssl.SSLException: Unsupported record version Unknown-0.0
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
ssl异常:将jdbc配置文件中设置:useSSL=false
(2)linux中出现错误 查看运行时错误
tomcat-->logs--> cat catalina.out
8.dubbo 无法连接到zookeeper:防火墙/ip问题
cause: KeeperErrorCode = ConnectionLoss for /dubbo
tomcat:VM options:-Dproject.env=pressure
9.service向mapper传递多个参数的时候 再mapper接口层接收参数要使用@param
service:
tbItemMapper.reduceInventory(itemId, num1-num);
mapper:
int reduceInventory(@Param("itemId") String itemId, @Param("num") Integer num) ;