Archetype Created Web Application/index.jspcontextConfigLocationclasspath:applicationContext.xmlorg.springframework.web.context.ContextLoaderListenerencodingFilterorg.springframework.web.filter.CharacterEncodingFiltertrueencodingUTF-8encodingFilter/*SpringMVCorg.springframework.web.servlet.DispatcherServletcontextConfigLocationclasspath:spring-mvc.xml1trueSpringMVC/
9、编写服务端代码
编写User实体类,代码如下:
package cn.temptation.domain;
/**
* 用户信息
*/
public class User {
// 成员变量
private Integer userid;
private String username;
private String password;
// 构造函数
public User() {
super();
}
public User(Integer userid, String username, String password) {
super();
this.userid = userid;
this.username = username;
this.password = password;
}
// 成员方法
public Integer getUserid() {
return userid;
}
public void setUserid(Integer userid) {
this.userid = userid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
编写UserController控制器,代码如下:
package cn.temptation.web;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import cn.temptation.dao.UserDao;
import cn.temptation.domain.User;
/**
* 用户控制器
*/
@Controller
@RequestMapping(value = "/user")
public class UserController {
@Resource
private UserDao userDao;
@RequestMapping("/view")
public String view() {
return "main/login";
}
@RequestMapping("/indexview")
public String index() {
return "main/index";
}
@RequestMapping(value = "/login", method = RequestMethod.POST)
public ModelAndView login(User model, HttpSession session) {
User user = userDao.findByUsername(model.getUsername());
if (user == null || !user.getPassword().equals(model.getPassword())) {
return new ModelAndView("redirect:/login.jsp");
} else {
session.setAttribute("user", user);
ModelAndView mav = new ModelAndView();
mav.setViewName("index");
return mav;
}
}
}
编写UserDao数据访问层接口,代码如下:
package cn.temptation.dao;
import cn.temptation.domain.User;
public interface UserDao {
public abstract User findByUsername(String username);
}
Annotation: 译为注释或注解
An annotation, in the Java computer programming language, is a form of syntactic metadata that can be added to Java source code. Classes, methods, variables, pa
定义:pageStart 起始页,pageEnd 终止页,pageSize页面容量
oracle分页:
select * from ( select mytable.*,rownum num from (实际传的SQL) where rownum<=pageEnd) where num>=pageStart
sqlServer分页:
 
hello.hessian.MyCar.java
package hessian.pojo;
import java.io.Serializable;
public class MyCar implements Serializable {
private static final long serialVersionUID = 473690540190845543
回顾简单的数据库权限等命令;
解锁用户和锁定用户
alter user scott account lock/unlock;
//system下查看系统中的用户
select * dba_users;
//创建用户名和密码
create user wj identified by wj;
identified by
//授予连接权和建表权
grant connect to
/*
*访问ORACLE
*/
--检索单行数据
--使用标量变量接收数据
DECLARE
v_ename emp.ename%TYPE;
v_sal emp.sal%TYPE;
BEGIN
select ename,sal into v_ename,v_sal
from emp where empno=&no;
dbms_output.pu
public class IncDecThread {
private int j=10;
/*
* 题目:用JAVA写一个多线程程序,写四个线程,其中二个对一个变量加1,另外二个对一个变量减1
* 两个问题:
* 1、线程同步--synchronized
* 2、线程之间如何共享同一个j变量--内部类
*/
public static