I am created some jsp file that returns as a response some json string. But I see that the Content-Type is set to txt automatically
My jsp code looks like
<%@ page import="java.util.Random" %>
<%@ page language="java" %>
<%@ page session="false" %>
<%
String retVal = "// some json string";
int millis = new Random().nextInt(1000);
// System.out.println("sleeping for " + millis + " millis");
Thread.sleep(millis);
%>
<%=retVal%>
How can I perform something like
setHeader("Content-Type", "application/json");
in this example?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…