⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractajaxhtmlaction.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
字号:
package com.sslexplorer.ajax;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.sslexplorer.boot.Util;
import com.sslexplorer.core.actions.AuthenticatedAction;

/**
 * Abstract action for use by action implementations that returns HTML documents 
 * or fragments for use by Ajax scripts.
 * <p>
 * Implementations will probably require some attributes to be passed. 
 * 
 * @author Brett Smith <a href="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
 * @version $Revision: 1.1 $
 */

public abstract class AbstractAjaxHTMLAction extends AuthenticatedAction {
    
    final static Log log = LogFactory.getLog(AbstractAjaxHTMLAction.class);

    /**
     * Handle the request
     * 
     * @param mapping mapping
     * @param form form
     * @param request request
     * @param response response
     * @param buf string buffer
     * @throws Exception on any array
     */
    protected abstract void onAjaxRequest(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                    HttpServletResponse response, StringBuffer buf) throws Exception;

    /* (non-Javadoc)
     * @see com.sslexplorer.core.actions.AuthenticatedAction#onExecute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
    protected ActionForward onExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                    HttpServletResponse response) throws Exception {
        try {
            StringBuffer buf = new StringBuffer();
            onAjaxRequest(mapping, form, request, response, buf);            

            // Set content to html
            response.setContentType("text/html; charset=UTF-8");
            Util.noCache(response);
            PrintWriter pw = response.getWriter();
            pw.write(buf.toString());
            pw.close();
        }
        catch(Exception e) {
            log.error("Error processing Ajax request.", e);
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error processing ajax request. " + e.getMessage());
        }
        return null;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -