首页 文章

在wildfly swarm中加载jsf字符串

提问于
浏览
1

我'm trying to run a jsf application on wildfly swarm but I'm在资源管理方面遇到了一些麻烦 . 他们在their github页面上的简短说明如下:

您需要以诸如deployment.addAsWebResource()之类的方式将xhtml文件添加到Shrinkwrap,因为JSF是非静态的 .

我没有设法识别我的捆绑文件 . 此外,我有大约20个.properties文件,其中包含字符串 . 我真的需要以编程方式添加所有这些吗?

<f:loadBundle basename="strings.strings"> Can't find bundle for base name strings.strings, locale en_US

在我的主要方法中,我有:

deployment.addAsWebResource(
            new ClassLoaderAsset("strings/strings.properties", Main.class.getClassLoader()), "strings.strings");

2 回答

  • 2

    链接到的JSF示例使用Shrinkwrap来自定义容器和部署 .

    如果您不需要自定义任何内容,它可以自动获取资源,如https://github.com/wildfly-swarm/wildfly-swarm-examples/tree/master/jsf/jsf-war

  • 0

    我有同样的问题,我的资源文件夹中的包 . 当我将它注入bean并从网页执行操作时它会查找并显示消息,但是当需要的字段为空时全部失败并且我收到消息

    java.util.MissingResourceException: Can't find bundle for base name messages, locale en
        at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
        at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
        at java.util.ResourceBundle.getBundle(ResourceBundle.java:1082)
        at javax.faces.component.MessageFactory.getMessage(MessageFactory.java:161)
        at javax.faces.component.MessageFactory.getMessage(MessageFactory.java:251)
        at javax.faces.component.UIInput.validateValue(UIInput.java:1149)
        at javax.faces.component.UIInput.validate(UIInput.java:982)
    
    
    
     @ManagedProperty("#{i18n}")
            private ResourceBundle bundle = null;
    
       public String loginUser() {
            FacesContext context = FacesContext.getCurrentInstance();
            ExternalContext ex = context.getExternalContext();       
    
            FacesMessage msg = new FacesMessage(bundle.getString("nouser"), bundle.getString("nouser"));
            FacesContext.getCurrentInstance().addMessage(null, msg);
            return
    

相关问题