[TEEDA-211] Content-Typeの設定の制御を変更する([Seasar-user:5567][S2JSF]xhmlについて Created: 2006-12-25  Updated: 2006-12-26  Resolved: 2006-12-26

Status: Resolved
Project: Teeda
Component/s: Teeda Core
Affects Version/s: 1.0.2
Fix Version/s: 1.0.3

Type: New Feature Priority: Major
Reporter: yone Assignee: yone
Resolution: Fixed Votes: 0
Labels: None


 Description   

org.seasar.teeda.core.taglib.core.ViewTagを

ViewTag
    public int doStartTag() throws JspException {
        final int rc = super.doStartTag();
        final FacesContext context = FacesContext.getCurrentInstance();
        AssertionUtil.assertNotNull("FacesContext", context);
        final String encoding = PageContextUtil
                .getCharacterEncoding(pageContext);
        pageContext.getResponse().setLocale(context.getViewRoot().getLocale());
        final String acceptContentTypes = WebAppUtil.getAcceptHeader(context);
// >> 追加
        if( acceptContentTypes != null)
        {
// <<追加
        final String contentType = ContentTypeUtil
                .getContentType(acceptContentTypes);
        pageContext.getResponse().setContentType(
                contentType + "; charset=" + encoding);
// >> 追加
        }
// <<追加

とすべきでは、ないでしょうか?
Acceptが指定されなかった場合は、JSPにお任せし、
Acceptが指定された場合は、Content-Typeを設定すべきと考えますが、
どうでしょうか?



 Comments   
Comment by yone [ 2006-12-26 ]

対応しました。
Content-typeの判定方法を以下のように若干見直ししました。

ContentTypeUtil.java
    public static boolean isHtmlContentType(String type) {
        return type.indexOf(JsfConstants.HTML_CONTENT_TYPE) != -1
                || type.equals(JsfConstants.ANY_CONTENT_TYPE);
    }

    public static boolean isXmlContentType(String type) {
        return type.indexOf(JsfConstants.XHTML_CONTENT_TYPE) != -1
                || type.indexOf(JsfConstants.APPLICATION_XML_CONTENT_TYPE) != -1
                || type.indexOf(JsfConstants.TEXT_XML_CONTENT_TYPE) != -1;
    }
Generated at Wed Apr 24 15:10:05 JST 2024 using Jira 9.15.0#9150000-sha1:9ead8528714127d8cfabf2446010d7e62c0a195c.