2016.7.1
来源:互联网 发布:四维星瓷砖设计软件 编辑:程序博客网 时间:2024/04/29 04:49
一、修改用户信息(1个页面+2个control)
一个页面:用于显示用户信息(display.jsp)
一个control:用户信息在后台从session中拿到(
User user = request.getSession.getAttribute(“user”); )然后放到request中(
Request.setattribute(“user_name”, username);````)在前台通过jquery拿到$(user_name)显示出来
另一个control:修改信息的链接:updateInfo.do
从session中拿到用户信息,从前端拿到修改的信息。通过用户信息中的ID去修改用户信息,然后重新设置session。返回用户信息页面。
二、写sql传参数(传的参数是个对象)
1、
public interface UpdateMapper {
@UpdateProvider(method ="updateInfo", type =UpdateSQL.class)
public int updateInfo(@Param("userId")int uerId,@Param("uerNewInfo")Enterprise_user uerNewInfo);
//当传入的值是个对象,在sql中用map映射
}
2、 //设置值得时候要加引号
public String updateInfo(Map<String,Object> map) {
Enterprise_user uerNewInfo = (Enterprise_user) map.get("uerNewInfo");//使用map拿到参数对象
String sql = "update z_enterprinse_users set user_name='"+uerNewInfo.getUser_name()+"', passwd='"+uerNewInfo.getPasswd()+"', email='"+uerNewInfo.getEmail()+"', mobile='"+uerNewInfo.getMobile()+"' where id=#{userId}";
return sql;
}
3. Model map的作用
Public String getAllPaper(HttpServletRequestrequest,Map<String,Object> model){
model.put("passwd", passwd);
}
ModelMap
ModelMap对象主要用于传递控制方法处理数据到结果页面,也就是说我们把结果页面上需要的数据放到ModelMap对象中即可,他的作用类似于 request对象的setAttribute方法的作用,用来在一个请求过程中传递处理的数据。通过以下方法向页面传递参数:
addAttribute(String key,Object value);
在页面上可以通过el变量方式$key或者bboss的一系列数据展示标签获取并展示modelmap中的数据。
4.从session中获取值,得到的值是个对象
String username =
request.getSession().getAttribute("username").toString();
5.验证sql写的是否正确
StringBuffer sb=new StringBuffer();
sb.append("select count(userId) from user where 1=1 ");
Sb.append(“”);
Sb.append(“”);
System.out.println("sql::::::::::"+sb.toString());
6.在mysql中,时间的数据类型是:datetime
7.设置rowcount时,设置pagecount
public void setRowCount(int rowCount) {
this.rowCount = rowCount;
setPageCount();
}
public void setPageCount() {
if(rowCount%pageSize==0){
this.pageCount =rowCount/pageSize;
}else{
this.pageCount = (rowCount/pageSize)+1;
}
}
8.form直接提交
<form action="<%=basePath%>test/test.do">
<input name="name" value="nihao">
<input name="age" value="26">
<button type="submit">测试</button>
</form>
- 2016.7.1
- leetcode题解日练--2016.7.1
- java se作业1--2016.7.19
- 2016.7.6笔记(1)-排序算法(内排)
- 2016.7.2
- 2016.7.4
- 2016.7.7
- 2016.7.7
- 2016.7.8
- 2016.7.6
- 2016.7.7
- 2016.7.8
- 2016.7.5
- 2016.7.12
- 2016.7.13
- 2016.7.15
- 2016.7.15
- 2016.7.18
- adb bash
- android-studio 2.2版本升级(踩坑)记
- 分布式、集群、负载均衡概念笔记
- PHP电商购物车(一:建立数据表)
- Android——Intent总结
- 2016.7.1
- UOJ 34 多项式乘法
- 来讲一下Enum
- 回文字符串
- UOJ 34 多项式乘法
- OOP-----类与对象对象
- 我真不黑博士
- 在数组 arr 末尾添加元素 item。不要直接修改数组 arr,结果返回新的数组
- 抽象与封装