viewdispatcher.java

来自「java ejb----html jsp」· Java 代码 · 共 52 行

JAVA
52
字号
package com.genuitec.traderx.web;

import java.util.ArrayList;

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


public class ViewDispatcher {

    public static final String ERROR_URL = "/jsp/error.jsp";

    public static void displayErrors(
        HttpServletRequest theRequest,
        HttpServletResponse theResponse,
        ArrayList theErrors) {

        theRequest.setAttribute("errors", theErrors);

        includeRequest(theRequest, theResponse, ERROR_URL);

    }

    public static void displayError(
        HttpServletRequest theRequest,
        HttpServletResponse theResponse,
        String theError) {
        ArrayList errors = new ArrayList();
        errors.add(theError);
        displayErrors(theRequest, theResponse, errors);
    }

    public static void includeRequest(
        HttpServletRequest theRequest,
        HttpServletResponse theResponse,
        String theURL) {

        try {
            theRequest.getRequestDispatcher(theURL).include(theRequest, theResponse);
        } catch (Exception ex) {
            //ex.printStackTrace(theResponse.getWriter());
        }
    }

    /**
     * Constructor for ErrorHandler.
     */
    private ViewDispatcher() {
        super();
    }

}

⌨️ 快捷键说明

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