Java Web学习笔记

来源:互联网 发布:关联交易 数据库 编辑:程序博客网 时间:2024/05/20 22:04

2017.10.17

在网上找了一些java web后台管理系统,最终选用BootDo。


Spring Boot:

https://www.tianmaying.com/tutorial/spring-boot-overview


Spring MVC快速入门:

https://www.tianmaying.com/tutorial/spring-mvc-quickstart


druid 是阿里巴巴的开源数据库连接池,和c3p0应该是同一种东西

如果是更改连接的数据库,应当引入对应数据库的driver,maven引入可以在model设置里引入,引入成功会在idea左侧External Libraries里看到。


bootdo使用的列表控件是bootstrap table,控件包括了底部的翻页按钮。详细使用文档:

http://bootstrap-table.wenzhixin.net.cn/zh-cn/documentation/

需要注意的是返回为total,rows


页面内弹窗控件用的是layui的layer,文档:

http://www.layui.com/doc/


关于maven:

在pom文件引入之后,需要在Maven Projects栏里点击刷新按钮,才能在Dependencies里显示


关于shiro:

自己新增加了城市列表管理的系列权限,包括查看页面,数据增删改查,发现只有顶层起作用,也就是如果给予查看页面权限,那么就算是没有给予增删改查权限,也可以增删改查,一直找不到原因。最终发现,权限命名方式有问题。我把查看页面权限命名为app:city,增加权限命名为app:city:add,这样如果一个用户被赋予查看页面权限,那么他也获得了增加权限。应该把查看页面权限命名为app:city:city。


2017.12.1

使用HttpServerRequest的getInputStream来获取POST的Streaming流,原来在Jetty时好用,但是迁移到SpringBoot后,无法获得流。

经过各种查资料,终于在一个安静的小角落,发现了解决方案。

原因是content type的问题。发post请求没有指定content type,默认为application/x-www-form-urlencoded。

spring boot 会把这种请求consum掉,导致无法获取到stream。所以指定content type为application/octet-stream,问题解决。

https://github.com/spring-projects/spring-boot/issues/4782

https://stackoverflow.com/questions/8522568/why-is-httpservletrequest-inputstream-empty


2017.12.20

postgresql主键不必加索引:

> If I have a primary key constraint defined in the database do I also 
> need to create an index on that field for fast lookup? 

No. Declaring field(s) as the primary key automatically adds a UNIQUE 
constraint on those fields. PostgreSQL implements unique constraints 
using a unique-constrained index. 

PostgreSQL tells you about this when you create a table. 

craig=> CREATE TABLE j ( y INTEGER PRIMARY KEY ); 
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "j_pkey" 
for table "j" 

http://www.postgresql-archive.org/Is-the-primary-key-constraint-also-an-index-td1905964.html

postgresql唯一列不必加索引:

不需要手工在唯一列上创建索引,如果那样做也只是重复了自动创建的索引而已。

http://www.postgres.cn/docs/9.6/indexes-unique.html