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

link.jfire.mvc.view.JsonView Maven / Gradle / Ivy

package link.jfire.mvc.view;

import java.io.OutputStream;
import java.nio.charset.Charset;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import link.jfire.codejson.JsonTool;

public class JsonView implements View
{
    private static Charset charset = Charset.forName("utf8");
    
    @Override
    public void render(HttpServletRequest request, HttpServletResponse response, Object result) throws Throwable
    {
        response.setContentType("application/json");
        OutputStream out = response.getOutputStream();
        out.write(JsonTool.write(result).getBytes(charset));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy