本文整理汇总了Java中org.apache.wicket.request.http.WebResponse.setContentType方法的典型用法代码示例。如果您正苦于以下问题:Java WebResponse.setContentType方法的具体用法?Java WebResponse.setContentType怎么用?Java WebResponse.setContentType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.wicket.request.http.WebResponse
的用法示例。
在下文中一共展示了WebResponse.setContentType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: respond
import org.apache.wicket.request.http.WebResponse; //导入方法依赖的package包/类
@Override
public void respond(IRequestCycle requestCycle) {
String script = ToastrHelper.generateJs(singularException, ToastrType.ERROR, false);
WebResponse response = (WebResponse)requestCycle.getResponse();
final String encoding = Application.get()
.getRequestCycleSettings()
.getResponseRequestEncoding();
// Set content type based on markup type for page
response.setContentType("text/xml; charset=" + encoding);
// Make sure it is not cached by a client
response.disableCaching();
response.write("<?xml version=\"1.0\" encoding=\"");
response.write(encoding);
response.write("\"?>");
response.write("<ajax-response>");
response.write("<evaluate><![CDATA[" + script + "]]></evaluate>");
response.write("</ajax-response>");
}
示例2: HtmlIFramePanel
import org.apache.wicket.request.http.WebResponse; //导入方法依赖的package包/类
public HtmlIFramePanel(String id, final IModel<String> htmlModel) {
super(id);
IResource resource = new IResource() {
@Override
public void respond(Attributes attributes) {
WebResponse response = (WebResponse) attributes.getResponse();
response.setContentType("text/html; charset=utf-8");
response.write(htmlModel.getObject());
}
};
setResource(resource);
}
示例3: respond
import org.apache.wicket.request.http.WebResponse; //导入方法依赖的package包/类
@Override
public void respond(Attributes attributes) {
if (mainPage.getNanopub() == null) return;
WebResponse resp = (WebResponse) attributes.getResponse();
RDFFormat format = mainPage.getFormat();
if (format == null) {
format = mainPage.getFormat();
}
if (format == null) {
format = RDFFormat.TRIG;
}
resp.setContentType(format.getMIMETypes().get(0));
resp.setAttachmentHeader("nanopub." + format.getDefaultFileExtension());
try {
NanopubUtils.writeToStream(mainPage.getNanopub(), resp.getOutputStream(), format);
} catch (Exception ex) {
ex.printStackTrace();
}
resp.close();
}
示例4: newStringResponse
import org.apache.wicket.request.http.WebResponse; //导入方法依赖的package包/类
private WebResponse newStringResponse() {
WebResponse response = (WebResponse) getResponse();
response.setContentType("text/plain");
response.write(responseText());
response.flush();
response.setStatus(HttpStatus.OK.value());
return response;
}
示例5: Result
import org.apache.wicket.request.http.WebResponse; //导入方法依赖的package包/类
private Result(WebResponse response, int status, String contentType) {
this.status = status;
this.contentType = contentType;
response.setStatus(status);
response.setContentType(contentType);
}
示例6: serializeObjectToResponse
import org.apache.wicket.request.http.WebResponse; //导入方法依赖的package包/类
/**
* Method invoked to serialize the result of the invoked method and write
* this value to the response.
*
* @param response
* The current response object.
* @param result
* The object to write to response.
* @param restMimeFormats
*/
private void serializeObjectToResponse(WebResponse response, Object result, String mimeType) {
try {
response.setContentType(mimeType);
objSerialDeserial.objectToResponse(result, response, mimeType);
} catch (Exception e) {
throw new RuntimeException("Error writing object to response.", e);
}
}