当前位置: 首页>>代码示例>>Java>>正文


Java WebScriptResponse.setHeader方法代码示例

本文整理汇总了Java中org.springframework.extensions.webscripts.WebScriptResponse.setHeader方法的典型用法代码示例。如果您正苦于以下问题:Java WebScriptResponse.setHeader方法的具体用法?Java WebScriptResponse.setHeader怎么用?Java WebScriptResponse.setHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.extensions.webscripts.WebScriptResponse的用法示例。


在下文中一共展示了WebScriptResponse.setHeader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handle

import org.springframework.extensions.webscripts.WebScriptResponse; //导入方法依赖的package包/类
private void handle(WebScriptRequest req, WebScriptResponse res) throws JSONException, IOException
{
    // create map of template vars
    String modelQName = req.getParameter("modelQName");
    if(modelQName == null)
    {
        throw new WebScriptException(
                Status.STATUS_BAD_REQUEST,
                "URL parameter 'modelQName' not provided.");
    }

    ModelDefinition.XMLBindingType bindingType = ModelDefinition.XMLBindingType.DEFAULT;
    AlfrescoModel model = solrTrackingComponent.getModel(QName.createQName(modelQName));
    res.setHeader("XAlfresco-modelChecksum", String.valueOf(model.getModelDef().getChecksum(bindingType)));
    model.getModelDef().toXML(bindingType, res.getOutputStream());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:17,代码来源:AlfrescoModelGet.java

示例2: streamContentImpl

import org.springframework.extensions.webscripts.WebScriptResponse; //导入方法依赖的package包/类
protected void streamContentImpl(WebScriptRequest req, WebScriptResponse res, 
        ContentReader reader, NodeRef nodeRef, QName propertyQName, 
        boolean attach, Date modified, String eTag, String attachFileName)
        throws IOException
{
    delegate.setAttachment(req, res, attach, attachFileName);

    // establish mimetype
    String mimetype = reader.getMimetype();
    String extensionPath = req.getExtensionPath();
    if (mimetype == null || mimetype.length() == 0)
    {
        mimetype = MimetypeMap.MIMETYPE_BINARY;
        int extIndex = extensionPath.lastIndexOf('.');
        if (extIndex != -1)
        {
            String ext = extensionPath.substring(extIndex + 1);
            mimetype = mimetypeService.getMimetype(ext);
        }
    }

    // set mimetype for the content and the character encoding + length for the stream
    res.setContentType(mimetype);
    res.setContentEncoding(reader.getEncoding());
    res.setHeader("Content-Length", Long.toString(reader.getSize()));

    // set caching
    Cache cache = new Cache();
    cache.setNeverCache(false);
    cache.setMustRevalidate(true);
    cache.setMaxAge(0L);
    cache.setLastModified(modified);
    cache.setETag(eTag);
    res.setCache(cache);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:36,代码来源:ContentInfo.java

示例3: setAttachment

import org.springframework.extensions.webscripts.WebScriptResponse; //导入方法依赖的package包/类
/**
 * Set attachment header
 * 
 * @param req WebScriptRequest
 * @param res WebScriptResponse
 * @param attach boolean
 * @param attachFileName String
 */
public void setAttachment(WebScriptRequest req, WebScriptResponse res, boolean attach, String attachFileName)
{
    if (attach == true)
    {
        String headerValue = "attachment";
        if (attachFileName != null && attachFileName.length() > 0)
        {
            if (logger.isDebugEnabled())
                logger.debug("Attaching content using filename: " + attachFileName);

            if (req == null)
            {
                headerValue += "; filename*=UTF-8''" + URLEncoder.encode(attachFileName)
                        + "; filename=\"" + filterNameForQuotedString(attachFileName) + "\"";
            }
            else
            {
                String userAgent = req.getHeader(HEADER_USER_AGENT);
                boolean isLegacy = (null != userAgent) && (userAgent.contains("MSIE 8") || userAgent.contains("MSIE 7"));
                if (isLegacy)
                {
                    headerValue += "; filename=\"" + URLEncoder.encode(attachFileName);
                }
                else
                {
                    headerValue += "; filename=\"" + filterNameForQuotedString(attachFileName) + "\"; filename*=UTF-8''"
                            + URLEncoder.encode(attachFileName);
                }
            }
        }
        
        // set header based on filename - will force a Save As from the browse if it doesn't recognize it
        // this is better than the default response of the browser trying to display the contents
        res.setHeader("Content-Disposition", headerValue);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:45,代码来源:ContentStreamer.java


注:本文中的org.springframework.extensions.webscripts.WebScriptResponse.setHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。