- 博客(29)
- 收藏
- 关注
原创 JUnit 4 with Hamcrest
A good starting place is the assertThat() method that can now almost always be used in place of the traditional assertEquals(). assertThat() can be found in org.junit.Assert, but it defines using Hamc
2014-08-26 12:42:15 597
原创 linux shell
#!/bin/shfor line in $(cat all_files.txt)do if [ -f "$line" ]; #A folder like /tmp/a/b is also true for -e, there is a whitespace before and after "-f". then sed 's/abc/def/g' $line >> ${line%.*
2014-08-25 21:24:26 387
原创 Bash Shell:判断文件是否存在
#!/bin/bashfile="/etc/hosts"if [ -f "$file" ]then echo "$file found."else echo "$file not found."fi
2014-08-25 18:20:07 769
原创 junit
我们先来看一个测试case: @Test public void test3() { ArrayList strings = new ArrayList(); strings.add("a"); strings.add("d"); strings.add("c"); strings.add("b");
2014-08-25 16:22:20 591
原创 h2数据库数据查看
如果想要查看数据库信息,可在web.xml文件中加入如下配置: H2Console org.h2.server.web.WebServlet 1 H2Console /memerydb/console/* 浏览器中输入:http://localhost:8080/memerydb
2014-08-25 08:54:12 3337
原创 div标签以及jsp中嵌入java代码
<% List files = (List) request.getAttribute("files"); if (files.size() > 2) { %> Click here to see more files... <% } %>
2014-08-22 15:22:38 1411
原创 文件上传操作
@RequestMapping(value = "/upload", method = RequestMethod.POST) public String upload(@RequestParam("files") MultipartFile[] files, Model model) { MyFile myFile = new MyFile(); Str
2014-08-22 12:55:05 539
原创 Shell: How to read lines in a file.
for line in $(cat all_files.txt )do echo $linedone
2014-08-20 16:36:54 497
转载 Mybatis ResultMap的使用
MyBatis 会在幕后自动创建一个 ResultMap,基于属性名来映射列到 JavaBean 的属性上。如果列名没有精确匹配,你可以在列名上使用 select 字句的别名(一个 基本的 SQL 特性)来匹配标签。比如: select user_id as "id", user_name as "userName",
2014-08-14 11:53:24 513
原创 mybatis, spring基于mapper文件和注解的集成
1. org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.Integer'
2014-08-13 13:46:06 733
原创 h2内存数据库和mysql数据库的区别
h2内存数据库:DROP table if exists 'q_user';CREATE TABLE `q_user` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键', `user_id` varchar(32) NOT NULL COMMENT '用户唯一标识', `nickname` varchar(32) NOT
2014-08-13 01:00:39 19516
原创 mybatis接口实现
1. dao.xml<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context
2014-08-12 21:58:40 578
原创 用户更新的sql语句
update(User user)的实现:private final String UPDATE_USER = "UPDATE q_user SET user_id = ?, nickname = ?, realname = ?,password = ?, email = ?,status = ?, last_login_time = ? WHERE id = ? ";
2014-08-12 14:35:13 1249
转载 拦截器验证用户是否登录
public class LoginInterceptor implements HandlerInterceptor { private static final Logger LOGGER = LoggerFactory.getLogger(LoginInterceptor.class); @Override public boolean preHandle(Htt
2014-08-10 23:28:49 1370
转载 spring mvc 拦截器配置
dispatcher-servlet.xml<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/sc
2014-08-10 23:18:20 560
原创 cookie添加
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String userName = req.getParameter("uid"); String password = req.getParam
2014-08-10 16:07:28 340
转载 枚举
package com.demo.mybatis.sample.bean;public enum Role { USER(0, "普通用户"), MANAGER(1, "管理员"); private int code; private String text; private Role(int code, String text) { this.code = code;
2014-08-07 16:30:09 367
原创 controller内部跳转
1. 热 @RequestMapping(value = "/login", method = RequestMethod.POST) public String loginPost(@RequestParam String userId, @RequestParam String password) { User user = userService.query
2014-08-07 11:51:01 897
转载 Controller通过@RequestBody接收参数
@RequestMapping(value="/update.json") @ResponseBody public Object update(@RequestBody User user) { user.setStatus(1); user.setLast_login_time(new Date()); boolean resu
2014-08-06 16:53:52 2241
转载 jsp + jquery + json
<%-- Created by IntelliJ IDEA. User: xuan Date: 14-8-1 Time: 下午1:38 To change this template use File | Settings | File Templates.--%> update user info body{
2014-08-06 16:41:37 471
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人