求以下一段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";
展开
 我来答
12大力出奇迹123
2015-05-12
知道答主
回答量:36
采纳率:0%
帮助的人:22.9万
展开全部
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来执行插入操作并且加上事务。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式