org.apache.wicket.markup.html.WebPage.setHeaders()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.apache.wicket.markup.html.WebPage.setHeaders()方法的一些代码示例,展示了WebPage.setHeaders()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebPage.setHeaders()方法的具体详情如下:
包路径:org.apache.wicket.markup.html.WebPage
类名称:WebPage
方法名:setHeaders

WebPage.setHeaders介绍

[英]Subclasses can override this to set there headers when the Page is being served. By default 2 headers will be set

response.setHeader("Pragma", "no-cache"); 
response.setHeader("Cache-Control", "no-cache, max-age=0, must-revalidate");

So if a Page wants to control this or doesn't want to set this info it should override this method and don't call super.
[中]子类可以覆盖此设置,以便在提供页面时设置标题。默认情况下,将设置两个标题

response.setHeader("Pragma", "no-cache"); 
response.setHeader("Cache-Control", "no-cache, max-age=0, must-revalidate");

,因此如果页面想要控制此信息或不想设置此信息,则应覆盖此方法,并且不调用super。

代码示例

代码示例来源:origin: org.wamblee/wamblee-wicket-components

@Override
protected void setHeaders(WebResponse aResponse) {
  super.setHeaders(aResponse);
  behaviors.setHeaders(this, aResponse);
}

代码示例来源:origin: org.apache.wicket/com.springsource.org.apache.wicket

/**
 * @see org.apache.wicket.Page#configureResponse()
 */
protected void configureResponse()
{
  super.configureResponse();
  if (getWebRequestCycle().getResponse() instanceof WebResponse)
  {
    final WebResponse response = getWebRequestCycle().getWebResponse();
    setHeaders(response);
  }
}

代码示例来源:origin: org.ops4j.pax.wicket/pax-wicket-service

/**
 * @see org.apache.wicket.Page#configureResponse()
 */
@Override
protected void configureResponse()
{
  super.configureResponse();
  if (getWebRequestCycle().getResponse() instanceof WebResponse)
  {
    final WebResponse response = getWebRequestCycle().getWebResponse();
    setHeaders(response);
  }
}

代码示例来源:origin: apache/wicket

/**
 * Set-up response with appropriate content type, locale and encoding. The locale is set equal
 * to the session's locale. The content type header contains information about the markup type
 * (@see #getMarkupType()) and the encoding. The response (and request) encoding is determined
 * by an application setting (@see ApplicationSettings#getResponseRequestEncoding()). If null,
 * no xml decl will be written.
 * 
 * @param response
 *            The WebResponse object
 */
protected void configureResponse(final WebResponse response)
{
  // Users may subclass setHeader() to set there own headers
  setHeaders(response);
  // The response encoding is an application setting
  final String encoding = getApplication().getRequestCycleSettings()
    .getResponseRequestEncoding();
  final boolean validEncoding = (Strings.isEmpty(encoding) == false);
  final String contentType;
  if (validEncoding)
  {
    contentType = getMarkupType().getMimeType() + "; charset=" + encoding;
  }
  else
  {
    contentType = getMarkupType().getMimeType();
  }
  response.setContentType(contentType);
}

代码示例来源:origin: org.apache.wicket/wicket-core

/**
 * Set-up response with appropriate content type, locale and encoding. The locale is set equal
 * to the session's locale. The content type header contains information about the markup type
 * (@see #getMarkupType()) and the encoding. The response (and request) encoding is determined
 * by an application setting (@see ApplicationSettings#getResponseRequestEncoding()). If null,
 * no xml decl will be written.
 * 
 * @param response
 *            The WebResponse object
 */
protected void configureResponse(final WebResponse response)
{
  // Users may subclass setHeader() to set there own headers
  setHeaders(response);
  // The response encoding is an application setting
  final String encoding = getApplication().getRequestCycleSettings()
    .getResponseRequestEncoding();
  final boolean validEncoding = (Strings.isEmpty(encoding) == false);
  final String contentType;
  if (validEncoding)
  {
    contentType = getMarkupType().getMimeType() + "; charset=" + encoding;
  }
  else
  {
    contentType = getMarkupType().getMimeType();
  }
  response.setContentType(contentType);
}

相关文章