Pan_cras
pan_cras
2016-07-07 11:01
采纳率: 100%
浏览 1.1k

servlet3.0 异步更新数据库的实现

package com.lpmas.mkt.console.campaign.taurus.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lpmas.admin.business.AdminUserHelper;
import com.lpmas.admin.config.OperationConfig;
import com.lpmas.framework.web.HttpResponseKit;
import com.lpmas.mkt.console.campaign.taurus.bean.UserRepresentBean;
import com.lpmas.mkt.console.campaign.taurus.business.UserRepresentInfoBusiness;
import com.lpmas.mkt.console.campaign.taurus.config.MktConsoleConfig;
import com.lpmas.mkt.console.campaign.taurus.config.MktResource;

@WebServlet(urlPatterns = "/campaign/UserRepresentRefresh.do", asyncSupported = true)
public class UserRepresentRefresh extends HttpServlet {

private static final long serialVersionUID = 2218434995334526228L;

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    doPost(request, response);
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    AdminUserHelper adminHelper = new AdminUserHelper(request, response);

    if (!adminHelper.checkPermission(MktResource.CAMPAIGN_INFO, OperationConfig.SEARCH)) {
        return;
    }

    int userId = Integer.valueOf(request.getParameter("userId"));
    UserRepresentInfoBusiness userRepresentInfoBusiness = new UserRepresentInfoBusiness();

    UserRepresentBean resultBean = userRepresentInfoBusiness.createValidRepresentInfo(userId);

    request.setAttribute("AdminUserHelper", adminHelper);

    String path = MktConsoleConfig.PAGE_PATH + "UserRepresentList.jsp";

    if (resultBean != null) {
        HttpResponseKit.alertMessage(response, "处理成功", path);
    }else{
        HttpResponseKit.alertMessage(response, "处理失败", HttpResponseKit.ACTION_HISTORY_BACK);
    }
}
}

这样算不算异步?
userRepresentInfo是更新数据库的操作
HttpResponseKit.alertMessage是弹出信息

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

相关推荐