IntelliJ IDEA 开发环境配置

2017-02-17

IntelliJ IDEA 主要用于支持 Java、Scala、Groovy 等语言的开发工具,同时具备支持目前主流的技术和框架,擅长于企业应用、移动应用和 Web 应用的开发。

最近使用后觉得比eclipse强太多。初次使用要配置各种开发环境,所以记之。

配置Git

1.在官网https://git-scm.com/下载Git for windows并安装。

2.打开IntelliJ IDEA的设置界面,选择Version Control → Git:

Read More »


Spring Security保护方法

2017-02-13

Spring Security提供了三种不同的安全注解:

1.Spring Security自带的@Secured注解;

2.JSR-250的@RolesAllowed注解;

3.表达式驱动的注解,包括@PreAuthorize、@PostAuthorize、@PreFilter和 @PostFilter。

Read More »


Spring Security JSP标签库

2017-02-13

Spring Security提供了一套JSP标签库用于保护JSP视图。该库比较小,只提供了三个标签。

要使用这个库,先在JSP页首加入:

1
<%@ taglib uri="http://www.springframework.org/security/tags" prefix="sec" %>

该库包含的三个标签如下:

<security:accesscontrollist>:如果用户通过访问控制列表授予了指定的权限,那么渲染该标签体中的内容。

<security:authentication>:渲染当前用户认证对象的详细信息。

<security:authorize>:如果用户被授予了特定的权限或者SpEL表达式的计算结果为true,那么渲染该标签体中的内容。

Read More »


基于数据库用户认证

2017-02-09

实际开发中用户的信息一般存放在数据库表里,所以我们使用元素替代

现使用Mysql数据库演示,表结构如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
CREATE TABLE `role` (
`id` int(20) NOT NULL AUTO_INCREMENT COMMENT '角色编号',
`name` varchar(60) NOT NULL COMMENT '角色',
`note` varchar(100) DEFAULT NULL COMMENT '描述',
PRIMARY KEY (`id`)
);
CREATE TABLE `user` (
`id` int(20) NOT NULL AUTO_INCREMENT COMMENT '用户编号',
`username` varchar(60) NOT NULL COMMENT '用户名',
`password` varchar(60) NOT NULL COMMENT '密码',
`status` int(20) NOT NULL COMMENT '状态',
`note` varchar(100) DEFAULT NULL COMMENT '描述',
PRIMARY KEY (`id`)
);
CREATE TABLE `user_role` (
`role_id` int(20) NOT NULL COMMENT '角色编号',
`user_id` int(20) NOT NULL COMMENT '用户编号',
PRIMARY KEY (`role_id`,`user_id`),
CONSTRAINT `user_role_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`),
CONSTRAINT `user_role_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`)
);

Read More »

自定义Spring Security登录页

2017-02-07

虽然Spring Security框架给我们赠送了个登录页面,但这个页面过于简单,Spring Security允许我们自定义登录页。

准备工作

第一步在maven中加入Spring Security相关依赖(Spring MVC已搭建好)。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>

Read More »

Carrying data across redirect requests

2017-02-04

重定向请求传递数据主要有URL和flash两种方式:

URL

1
2
3
4
5
6
@RequestMapping(value="/redirect",method=RequestMethod.GET)
public String redirect(Model model){
model.addAttribute("name", "KangKang");
model.addAttribute("id", 1l);
return "redirect:/index/redirect/{name}";
}

重定向 URL路径将会是“/index/redirect/KangKang?id=1l”。

Read More »


Spring multipart上传下载

2017-01-24

加入依赖Apache Commons FileUpload:

1
2
3
4
5
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>

Read More »

Spring中使用Apache Tiles布局

2017-01-23

假设我们想为应用中的所有页面定义一个通用的头部和底部。最原始的方式就是查找每个JSP模板,并为其添加头部和底部的HTML。但是这种方法的扩展性并不好,也难以维护。更好的方式是使用布局引擎,如Apache Tiles,定义适用于所有页面的通用页面布局。Spring MVC以视图解析器的形式为Apache Tiles提供了支持。

Read More »


1…343536…45
Hosted  by  Coding Pages
MrBird
MrBird

A simple blog, code repository, just keep blogging

14 Archives 2 Labels
  • 🏠 Home
  • 📦 Archives
  • 🔖 Labels
  • 👬 Friends
  • 🔍 Search
  •   UV    PV 
    0