久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

javax.el.PropertyNotWritableException:/index.xhtml @29,118 va

javax.el.PropertyNotWritableException: /index.xhtml @29,118 value=quot;quot;: Illegal Syntax for Set Operation(javax.el.PropertyNotWritableException:/index.xhtml @29,118 value=: Set Operation 的非法語法) - IT屋-程序員軟件開發技術
本文介紹了javax.el.PropertyNotWritableException:/index.xhtml @29,118 value=""": Set Operation 的非法語法的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我想創建一個帶有本地化選項的登錄屏幕來翻譯名稱,當我從默認英語更改為阿拉伯語時它會崩潰

I want to create a login screen with localization option to translate the name and when i change from the default English to Arabic it crash

這里是 faces.config.xml

here is the faces.config.xml

<?xml version="1.0" encoding="UTF-8"?>
<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_0.xsd"
    version="2.0">
     <application>
           <locale-config>
                <default-locale>en</default-locale>
                <supported-locale>ar</supported-locale>
           </locale-config>
       <resource-bundle>
        <base-name>mypack.enar</base-name>
        <var>msg</var>
       </resource-bundle>
     </application>
</faces-config>

托管豆

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;

/**
 *
 * @author body
 */
@ManagedBean(name = "localize")
@RequestScoped
public class LocalizeMBean implements Serializable {

    /**
     * @return the countries
     */
    public static Map<String, Object> getCountries() {
        return countries;
    }

    /**
     * @param aCountries the countries to set
     */
    public static void setCountries(Map<String, Object> aCountries) {
        countries = aCountries;
    }

    private String localeCode;

    /**
     * Creates a new instance of LocalizeMBean
     */
    public void setLocaleCode(String localeCode) {
        this.localeCode = localeCode;
    }

    public Map<String, Object> getCountriesInMap() {
        return getCountries();
    }

    public String getLocaleCode() {
        return localeCode;
    }
    private static Map<String, Object> countries;

    static {
        setCountries(new LinkedHashMap<String, Object>());
        getCountries().put("English", Locale.ENGLISH); //label, value
        getCountries().put("Arabic", Locale.UNICODE_LOCALE_EXTENSION);
    }

    public void countryLocaleCodeChanged(ValueChangeEvent e) {

        String newLocaleValue = e.getNewValue().toString();

        //loop country map to compare the locale code
        for (Map.Entry<String, Object> entry : getCountries().entrySet()) {

            if (entry.getValue().toString().equals(newLocaleValue)) {

                FacesContext.getCurrentInstance()
                        .getViewRoot().setLocale((Locale) entry.getValue());

            }
        }
    }
}

JSF 頁面

<h:head>
        <title>My Login Page</title>
        <h:outputStylesheet library="mycss" name="login-box.css"/>
    </h:head>
    <h:body>
        <h:form>
            <div style="padding: 100px 0 0 250px;">


                <div id="login-box">

                    <H2>Login</H2>
                    My Login Screen
                    <br />
                    <h:selectOneMenu value="#{localize.localeCode}" onchange="submit();"
                                     valueChangeListener="#{localize.countryLocaleCodeChanged}">
                        <f:selectItems value="#{localize.countriesInMap}" /> 
                    </h:selectOneMenu>
                    <br />
                    <div id="login-box-name" style="margin-top:20px;">
                        <h:outputLabel value="#{msg.namee}" />
                    </div>
                    <div id="login-box-field" style="margin-top:20px;">
                        <h:inputText  styleClass="form-login" title="Username" value="" size="30" maxlength="2048" />
                    </div>
                    <div id="login-box-name">Password:</div><div id="login-box-field"><h:inputSecret styleClass="form-login" title="Password" value="" size="30" maxlength="2048" /></div>
                    <br />
                    <div class="login-box-options"><h:selectBooleanCheckbox value="1"/>Remember me<h:commandLink style="margin-left:30px;" value="Forget Password"/></div>
                    <br />
                    <br />
                    <h:commandButton styleClass="button"/>
                </div>
            </div>
        </h:form>
    </h:body>
</html>

我在組合框中更改時的異常

The Exception when i change in the combobox

javax.faces.component.UpdateModelException: javax.el.PropertyNotWritableException: /index.xhtml @29,118 value="": Illegal Syntax for Set Operation
    at javax.faces.component.UIInput.updateModel(UIInput.java:853)
    at javax.faces.component.UIInput.processUpdates(UIInput.java:735)
    at javax.faces.component.UIForm.processUpdates(UIForm.java:281)
    at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1242)
    at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1242)
    at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:1231)
    at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:78)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)
Caused by: javax.el.PropertyNotWritableException: /index.xhtml @29,118 value="": Illegal Syntax for Set Operation
    at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:136)
    at javax.faces.component.UIInput.updateModel(UIInput.java:818)
    ... 38 more

推薦答案

請仔細閱讀異常信息.答案就在那里.

Please carefully read the exception message. The answer is straight in there.

javax.el.PropertyNotWritableException:/index.xhtml @29,118 value="": 非法集操作語法

javax.el.PropertyNotWritableException: /index.xhtml @29,118 value="": Illegal Syntax for Set Operation

在第 29 行,/index.xhtml 的第 118 個字符,你有一個 value="".對于應該可以通過 setter 方法寫入的 EL 值表達式,這不是有效的語法.

At line 29, character 118 of /index.xhtml you've a value="". This is not a valid syntax for an EL value expression which should be writable through a setter method.

通常,您像 value="#{bean.property}" 這樣指定 value 屬性,其中 bean 有一個 getProperty() 和一個 setProperty() 方法符合 javabeans 規范.

Normally, you specify the value attribute like so value="#{bean.property}" wherein the bean has a getProperty() and a setProperty() method conform javabeans specification.

很可能是這個:

<h:inputText  styleClass="form-login" title="Username" value="" size="30" maxlength="2048" />

我不確定您為什么要這樣指定值.這是完全錯誤的.您應該完全刪除它

I'm not sure why you specified the value like that. This is plain wrong. You should either remove it altogether

<h:inputText  styleClass="form-login" title="Username" size="30" maxlength="2048" />

或將其綁定到有效的 bean 屬性

or bind it to a valid bean property

<h:inputText  styleClass="form-login" title="Username" value="#{someBean.userName}" size="30" maxlength="2048" />

請注意,此問題與更改 JSF 語言環境無關.

Please note that this problem has nothing to do with changing the JSF locale.

與具體問題無關,嵌套表單在 HTML 中是非法,因此也在JSF中.您應該將語言選擇和用戶登錄拆分為 2 個單獨的表單.您不想在更改語言時提交登錄數據.此外,您可能會發現此答案中的提示有助于正確更改 JSF 語言環境:JSF 中的本地化,如何記住每個會話而不是每個請求/視圖選擇的語言環境

Unrelated to the concrete problem, nesting forms is illegal in HTML and therefore also in JSF. You should split the language selection and the user login over 2 separate forms. You don't want to submit the login data when you change the language. Further, you may find the hints in this answer helpful as to how to properly change the JSF locale: Localization in JSF, how to remember selected locale per session instead of per request/view

這篇關于javax.el.PropertyNotWritableException:/index.xhtml @29,118 value=""": Set Operation 的非法語法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 蜜桃视频在线观看免费视频网站www | 婷婷中文在线 | 精品一区二区久久久久久久网站 | 国产在线观看不卡一区二区三区 | 国产一区二区三区四区三区四 | 日日噜 | 中文字幕精品一区二区三区精品 | 国产成人精品一区二区三区在线 | 久久国品片| 香蕉视频在线播放 | 欧美日韩在线视频一区 | 日本黄色免费片 | 欧美一区二区三区在线观看 | 国产精品成人一区二区三区夜夜夜 | 天天宗合网 | av在线一区二区三区 | 免费a国产 | 国产91在线播放 | 九九热精品在线 | 久久久久无码国产精品一区 | 黄色大片免费网站 | 久久久久国产 | 国产精品96久久久久久 | 成人亚洲性情网站www在线观看 | 久草在线 | 国产精品一区二区欧美 | 毛片免费在线 | 国产中文原创 | 午夜av电影 | 天天色综 | 夜夜爆操 | 最新伦理片 | 一级毛片在线播放 | 日本粉嫩一区二区三区视频 | 91精品久久久久久久久久入口 | 最新中文字幕久久 | 久久精品高清视频 | 日本一二三区在线观看 | 成人国产精品久久 | 亚洲人成人一区二区在线观看 | 中文字幕一区二区三区四区五区 |