xmlrwloaderservlet.java

来自「一个关于tlms的一个小程序 看看能否帮助到别人」· Java 代码 · 共 73 行

JAVA
73
字号
/**
 * =============================================
 * Copyright 2005 TransFar
 *
 * Change Revision
 * --------------------------------
 *   Date        Author      Remarks
 *   2006-3-14     YHuang     Create class com.szmx.component.xml.rw.listener.XmlRwLoaderServlet
 * =============================================
 */
package com.szmx.component.xml.rw.servlet;

import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.context.ApplicationContext;
import org.apache.commons.lang.StringUtils;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;

import com.szmx.component.xml.rw.XmlBeanService;

/**
 *
 * @author YHuang
 * @version 1.0
 * @class com.szmx.component.xml.rw.listener.XmlRwLoaderServlet
 * @since 2006-3-14
 */
public class XmlRwLoaderServlet extends HttpServlet {

    private String xmlPath;
    private String dtdPath;
    private String beanName;

    public void setXmlPath(String xmlPath) {
        this.xmlPath = xmlPath;
    }

    public void setDtdPath(String dtdPath) {
        this.dtdPath = dtdPath;
    }

    public void setBeanName(String beanName) {
        this.beanName = beanName;
    }

    public void init() throws ServletException {
        super.init();
        if (xmlPath == null) {
            throw new ServletException("init error : the xml Path must config");
        }
        if(beanName==null){
            throw new ServletException("init error : the beanName must config");
        }
        ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
        XmlBeanService xmlBeanService = (XmlBeanService)ctx.getBean(this.beanName);
        xmlBeanService.setXmlPath(getServletContext().getRealPath(this.xmlPath));
        if(StringUtils.isNotEmpty(dtdPath)){
            xmlBeanService.setDtdPath(getServletContext().getRealPath(this.dtdPath));
        }
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    }

}

⌨️ 快捷键说明

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