求以下一段JAVA的代码注释
publicStringaddLeaverword()throwsException{HttpServletRequestrequest=ServletActionCon...
public String addLeaverword() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
Sysuser user = (Sysuser)request.getSession().getAttribute("admin");
LeaverwordDao dao = (LeaverwordDao)Info.getDao(request, "LeaverwordDao");
String mark = request.getParameter("mark");
String title = request.getParameter("title");
String type = request.getParameter("type");
String leaverName = user.getUname();
String userId=request.getParameter("userId");
Leaverword leaverword=new Leaverword();
leaverword.setTitle(title);
leaverword.setMark(mark);
leaverword.setType(type);
leaverword.setTime(new Date());
leaverword.setLeaverName(leaverName);
leaverword.setUserId(userId);
dao.insert(leaverword);
request.setAttribute("suc", "");
return "addLeaverword"; 展开
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
Sysuser user = (Sysuser)request.getSession().getAttribute("admin");
LeaverwordDao dao = (LeaverwordDao)Info.getDao(request, "LeaverwordDao");
String mark = request.getParameter("mark");
String title = request.getParameter("title");
String type = request.getParameter("type");
String leaverName = user.getUname();
String userId=request.getParameter("userId");
Leaverword leaverword=new Leaverword();
leaverword.setTitle(title);
leaverword.setMark(mark);
leaverword.setType(type);
leaverword.setTime(new Date());
leaverword.setLeaverName(leaverName);
leaverword.setUserId(userId);
dao.insert(leaverword);
request.setAttribute("suc", "");
return "addLeaverword"; 展开
1个回答
展开全部
public String addLeaverword() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();//得到request对象
HttpServletResponse response = ServletActionContext.getResponse();//得到response对象
Sysuser user = (Sysuser)request.getSession().getAttribute("admin");//session中找到名字叫“admin”的用户对象,应该是登录时存到这里的用户信息
LeaverwordDao dao = (LeaverwordDao)Info.getDao(request, "LeaverwordDao");//得到DAO 对象
String mark = request.getParameter("mark");//request对象中名字叫“mark”的属性,一般是前台传过来的值
String title = request.getParameter("title");//同上
String type = request.getParameter("type");//同上
String leaverName = user.getUname();//获取user对象中的uname属性
String userId=request.getParameter("userId");//前台传过来的usrid
Leaverword leaverword=new Leaverword(); //new一个对象
leaverword.setTitle(title);//对象中放值
leaverword.setMark(mark);
leaverword.setType(type);
leaverword.setTime(new Date());
leaverword.setLeaverName(leaverName);
leaverword.setUserId(userId);//同上
dao.insert(leaverword);//执行插入操作,把Leaverword存入数据库
request.setAttribute("suc", "");//request对象中suc属性设置为空值
return "addLeaverword";//返回值,如果是Struts就应该是返回页面。去Struts.xml里找跳转到哪里了。
//猜测这是一个action类,在action类里面直接调用dao不符合开发规范,建议多加一层service来执行插入操作并且加上事务。
HttpServletRequest request = ServletActionContext.getRequest();//得到request对象
HttpServletResponse response = ServletActionContext.getResponse();//得到response对象
Sysuser user = (Sysuser)request.getSession().getAttribute("admin");//session中找到名字叫“admin”的用户对象,应该是登录时存到这里的用户信息
LeaverwordDao dao = (LeaverwordDao)Info.getDao(request, "LeaverwordDao");//得到DAO 对象
String mark = request.getParameter("mark");//request对象中名字叫“mark”的属性,一般是前台传过来的值
String title = request.getParameter("title");//同上
String type = request.getParameter("type");//同上
String leaverName = user.getUname();//获取user对象中的uname属性
String userId=request.getParameter("userId");//前台传过来的usrid
Leaverword leaverword=new Leaverword(); //new一个对象
leaverword.setTitle(title);//对象中放值
leaverword.setMark(mark);
leaverword.setType(type);
leaverword.setTime(new Date());
leaverword.setLeaverName(leaverName);
leaverword.setUserId(userId);//同上
dao.insert(leaverword);//执行插入操作,把Leaverword存入数据库
request.setAttribute("suc", "");//request对象中suc属性设置为空值
return "addLeaverword";//返回值,如果是Struts就应该是返回页面。去Struts.xml里找跳转到哪里了。
//猜测这是一个action类,在action类里面直接调用dao不符合开发规范,建议多加一层service来执行插入操作并且加上事务。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询