在jsf2.1中配置资源包
我在引用xhtml文件中.properties文件中的资源值时遇到问题 我得到以下信息:在jsf2.1中配置资源包,jsf,primefaces,Jsf,Primefaces,我在引用xhtml文件中.properties文件中的资源值时遇到问题 我得到以下信息: Jul 23, 2012 8:33:27 PM com.sun.faces.context.ExternalContextImpl getMimeType WARNING: JSF1091: No mime type could be found for file hello. To resolve this, add a mime-type mapping to the applications web
Jul 23, 2012 8:33:27 PM com.sun.faces.context.ExternalContextImpl getMimeType
WARNING: JSF1091: No mime type could be found for file hello. To resolve this,
add a mime-type mapping to the applications web.xml.
这是我的faces-config.xml
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"
version="2.1">
<application>
<resource-bundle>
<base-name>resources.resources</base-name>
<var>resource</var>
</resource-bundle>
<locale-config>
<default-locale>en</default-locale>
</locale-config>
</application>
</faces-config>
资源
资源
EN
这是我的测试页面
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<f:view>
<h:head>
<h:outputText value="Header" />
</h:head>
<h:body>
<h:form>
<h:outputText value="#{resource.hello}" />
<h:outputText value="Body" />
<br />
<p:spinner />
</h:form>
</h:body>
</f:view>
</html>
有什么不对劲吗
编辑:
不确定这是否重要,我使用Primefaces-3.3.1
谢谢 EL变量{resource}
是一个保留变量名,它引用/resources
文件夹中的资源文件,这些文件由
、
和
使用。EL变量#{resource}
通常只在CSS文件中使用
.someClass{
背景图像:url(“#{resource['someLibrary:image/some.png']}”);
}
给它一个不同的名字
res
味精
文本
i18n
等
另见:
{resource}
是一个保留变量名,它引用/resources
文件夹中的资源文件,这些文件由
、
和
使用。EL变量#{resource}
通常只在CSS文件中使用
.someClass{
背景图像:url(“#{resource['someLibrary:image/some.png']}”);
}
给它一个不同的名字
res
味精
文本
i18n
等
另见:
后,您是否绝对肯定出现了此问题?如果不使用它,同样的问题应该仍然会出现。我打赌您的XHTML文件名为hello.XHTML
。您使用的是哪个servletcontainer impl/version?@BalusC,是的,问题仍然存在,是的,文件名为test.xhtml。我调试后发现,没有调用FacesResourceBundleeElResolver来解析属性。异常消息表明它无法解析文件hello
的mime类型。这与test.xhtml
不同。请修改您的问题和/或评论。另外,请从问题/代码中删除资源包噪音,因为这显然不是您具体问题的原因。嗯,我想我没有理解您的意思。我的测试页面名为test.xhtml。在该页面中,我访问#{resource.hello},键值对“hello=hello!”是在resources.properties文件中定义的。在添加和使用
之后,您是否绝对肯定出现了此问题?如果不使用它,同样的问题应该仍然会出现。我打赌您的XHTML文件名为hello.XHTML
。您使用的是哪个servletcontainer impl/version?@BalusC,是的,问题仍然存在,是的,文件名为test.xhtml。我调试后发现,没有调用FacesResourceBundleeElResolver来解析属性。异常消息表明它无法解析文件hello
的mime类型。这与test.xhtml
不同。请修改您的问题和/或评论。另外,请从问题/代码中删除资源包噪音,因为这显然不是您具体问题的原因。嗯,我想我没有理解您的意思。我的测试页面名为test.xhtml。在该页面中,我访问#{resource.hello},键值对“hello=hello!”是在resources.properties文件中定义的。感谢您的建议,我将在能够访问源代码时对其进行测试。感谢您的建议,我将在能够访问源代码时对其进行测试。