User user=getModel(User.class);
user.set("id", UUID.randomUUID().toString());
user.save();
2、登录时需要从前台获得用户名密码然后去数据库查询是否存在
String name=getPara("user.name");
String password=getPara("user.password");
List<User> l=User.dao.find("select * from user where name='"
+name+"' and password='"+password+"'");
3、保存和移除用户信息到session中
//保存session
getSession().setAttribute("username", name);
//移除session
getSession().removeAttribute("username");
4、前台使用jstl来判断显示不同的内容
<c:if test="${sessionScope.username!=null}">
<a href='/user/userInfo.jsp'>欢迎 ${sessionScope.username}</a>
<a href='/user/logout'>注销</a>
</c:if>
<c:if test="${sessionScope.username==null}">
<a href='/user/login.jsp'>登录</a>
<a href='/user/register.jsp'>注册</a>
</c:if>
jstl只有if没有else,所以用了两个if。分支多的时候可以用下面的标签
<c:choose>
<c:when test="${condition1}">
condition1为true
</c:when>
<c:when test="${ condition2}">
condition2为true
</c:when>
<c:otherwise>
condition1和condition2都为false
</c:otherwise>
</c:choose>
5、servlet api
http://tomcat.apache.org/tomcat-5.5-doc/servletapi/