質問

  1. I am setting a special character in DataModel.
    My DataModel

    public class LaunchModel implements Serializable {
    
        private List<LaunchModel> testquestionList;
        public LaunchModel() {
        testquestionList=new ArrayList<LaunchModel>();
        }
        //GETTER AND SETTER
    }
    

    My controller method..

    private void setdefaultValues() {
    
        LaunchModel temp=new LaunchModel();
        List<LaunchModel> tempList=new ArrayList<LaunchModel>();
        temp.setQuestion("ΔLMN and ΔXYZ");
        tempList.add(temp);
        this.launchModel.setTestquestionList(tempList);
    }
    

    My JSP page..

<h:form id="addAssessmentFormId" enctype="multipart/form-data">
    <t:div id="main" forceId="true">
        <t:dataList id="questionList" var="question"
            value="#{launchPlayer.launchModel.testquestionList}" rowIndexVar="index"
            layout="unorderedList" forceId="true">

            <t:div>
            <h:outputText id="que" value="#{question.question}" />
                <h:inputTextarea id="que" value="#{question.question}" />
            </t:div>
        </t:dataList>
        <t:div style="text-align:center;">
            <h:commandButton value="save" action="#{launchPlayer.testsaveAssessment}"></h:commandButton>
        </t:div>
    </t:div>


</h:form>

when it display that time it displays correct special character but when click on save button that time it change the value of String in junk character How it happens I dnt get it. How to solve this problem.

役に立ちましたか?

解決

Set default encoding in your jsp. That should do.

<%@ page language="java" pageEncoding="utf8" contentType="text/html;charset=UTF-8" %>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top