WARNING: JSF1091: No mime type could be found for file dynamiccontent

不羁岁月 提交于 2019-12-21 01:05:31

问题


I get the following warning under eclipse :

WARNING: JSF1091: No mime type could be found for file dynamiccontent. To resolve this, add a mime-type mapping to the applications web.xml

This error is caused when I post a picture

below primefaces composant :

<p:graphicImage  value="#{bean.image}"/>

Java Bean :

private StreamedContent image;

// Getter
public StreamedContent getImage() {
    try {
        JFreeChart jfreechart = ChartFactory.createPieChart3D("",
                        createDataset(), true, true, false);

        PiePlot3D plot = (PiePlot3D) jfreechart.getPlot();

        File chartFile = new File("dynamichart");
        ChartUtilities.saveChartAsPNG(chartFile, jfreechart, 375, 300);
        chartImage = new DefaultStreamedContent(new FileInputStream(
                        chartFile), "image/png");
        return chartImage;
    } catch (Exception e) {
        e.printStackTrace();
        return new DefaultStreamedContent();
    }
}

// generate data for image
public static PieDataset createDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("A",10);
    dataset.setValue("B", 11);
    dataset.setValue("C", 80);
    dataset.setValue("D", 12);
    return dataset;
}

回答1:


Try adding the following to your web.xml file

<mime-mapping>
    <extension>jsp <!--{or the extension of file}--></extension>
    <mime-type>text/html</mime-type>
  </mime-mapping>



回答2:


I found one solution.

by using the latest version of primefaces (3.5).

<dependency>  
    <groupId>org.primefaces</groupId>  
    <artifactId>primefaces</artifactId>  
    <version>3.5</version>  
</dependency> 

but there will unpleasant changes in IHM




回答3:


I had the JSF1091 warning for http://example.org  and javascript:; as well, with Icefaces instead of Primefaces.

Changing

<ice:outputLink onclick="..." value="javascript:;">...</ice:outputLink>

to

<ice:outputLink onclick="..." value="/some/url">...</ice:outputLink>

silenced the warning about javascript:;.

Changing

<ice:outputLink value="http://example.org"/>

to

<a href="http://example.org"/>

fixed it for the URL.




回答4:


Although I post this answer after a while probably it will be useful for other developers who face this problem.

To avoid that annoying warning from above add the following code into your web.xml :

<mime-mapping>
<extension>png</extension>
<mime-type>image/png</mime-type>
</mime-mapping>

For more details please check:

http://blog.eisele.net/2011/01/weblogic-10340-oepe-maven-primefaces.html




回答5:


I just want to share my experience with a similar problem, I use maven, netbeans and payara. Once I had this warning:

WARNING No mime type could be found for file fontawesome-webfont.woff is logged

The solution to remove this warning was adding the following code to the web.xml:

<mime-mapping>
    <extension>woff</extension>
    <mime-type>application/font-woff</mime-type>
</mime-mapping>

Note: I had the same warning with different files, those files had different extensions (woff, eot, woff2 and ttf). The solution to this was to replace woff in <extension> with one of the extensions previously mentioned.

I hope that my answer will help someone someday.

PS : I found the solution in this page.




回答6:


if you have spring you can also have (I added most of fa-Icons):

@Configuration
public class JsfConfigurationMimeMapper implements EmbeddedServletContainerCustomizer {

     @Override
     public void customize(ConfigurableEmbeddedServletContainer container) {
        MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
        mappings.add("xsd", "text/xml; charset=utf-8");
        mappings.add("otf", "font/opentype");
        mappings.add("ico", "image/x-icon");
        mappings.add("svg", "image/svg+xml");
        mappings.add("eot", "application/vnd.ms-fontobject");
        mappings.add("ttf", "application/x-font-ttf");
        mappings.add("woff", "application/x-font-woff");
        mappings.add("woff2", "application/x-font-woff2");
        mappings.add("xhtml", "application/xml");
        container.setMimeMappings(mappings);
    }
}


来源:https://stackoverflow.com/questions/14984154/warning-jsf1091-no-mime-type-could-be-found-for-file-dynamiccontent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!