// 初始化更新新闻页面,不使用ActionForm,主键通过URL由HttpServletRequest对象获取
 public ActionForward updateView(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   int num = Integer.parseInt(request.getParameter(Name.Property));
   String hql = "from News news where news.num='" + num + "'";
   News news = Controller.get(hql);
   request.getSession().setAttribute(Name.AdminNews, news);
   response.sendRedirect("news_update.jsp");
   return null;
 }
 // 处理事务:开启新闻或是关闭新闻,不使用ActionForm,主键通过URL由HttpServletRequest对象获取
 public ActionForward setIsUsed(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   int num = Integer.parseInt(request.getParameter(Name.Property));
   String hql = "from News news where news.num='" + num + "'";
   News news = Controller.get(hql);
   String code = request.getParameter("code");
   if ("start".equals(code)) {
     news.setIsUsed(true);
   } else {
     news.setIsUsed(false);
   }
   Controller.update(news);
   response.sendRedirect("news_view.do?method=viewList");
   return null;
 }
Beispiel #3
0
 public static String getName(int num) {
   String hql = "select shop.name from Shop shop where shop.num='" + num + "'";
   Object obj = Controller.get(hql);
   return (String) obj;
 }