All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fastchar.out.FastOutText Maven / Gradle / Ivy

There is a newer version: 2.2.2
Show newest version
package com.fastchar.out;

import com.fastchar.core.FastAction;
import com.fastchar.core.FastChar;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 响应输出文本
 */
public class FastOutText extends FastOut {

    public FastOutText() {
        this.contentType = "text/plain";
    }


    @Override
    public void response(FastAction action) throws Exception {
        HttpServletResponse response = action.getResponse();
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
        response.setStatus(getStatus());
        response.setContentType(toContentType());
        response.setCharacterEncoding(getCharset());

        try (PrintWriter writer = response.getWriter()) {
            writer.write(String.valueOf(data));
            writer.flush();
        }

    }
}






© 2015 - 2025 Weber Informatics LLC | Privacy Policy