Input value in modal screen is garbled (character garbled by TOMCAT)

Asked 1 years ago, Updated 1 years ago, 97 views

I created a modal screen with input in AngularJS.
The input tag is garbled when the server receives the input value.
In this case, where should I specify the character set?
(Also, the script for the modal screen is set with a meta tag.)

<script type="text/ng-template" id="SeikyusakiInsert">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <div class="modal-content">
            <div class="modal-header">
                <div class="modal-header modal-dialog-header">
                    <h3> Billing List</h3>
                </div>
            </div>
            <div class="modal-body modal-dialog-body-seikyusaki">
                <div class="form-group">
                    <label class="col-sm-3col-md-3col-lg-3 control-label" for="InputCompanyName">Company Name</label>
                    <div class="col-sm-6col-md-6col-lg-6">
                        <input type="text" class="form-control" name="CampanyName" id="CampanyName" ng-model="CampanyName" placeholder="Company name" size="20" maxlength="60">
                    </div>
                    <div class="col-sm-3col-md-3col-lg-3">
                        <fontcoloer="red">${ErrCampanyName}</font>
                    </div>
                </div>
                <br>
                <div class="form-group">
                    <label class="col-sm-3col-md-3col-lg-3 control-label" for="InputCampanyKanaName">Company Kana Name</label>
                    <div class="col-sm-6col-md-6col-lg-6">
                        <input type="text" class="form-control" name="CampanyKana" id="CampanyKana"ng-model="CampanyKana"placeholder="Company Kana" size="20"maxlength="60">
                    </div>
                    <div class="col-sm-3col-md-3col-lg-3">
                        <fontcoloer="red">${ErrCampanyKana}</font>
                    </div>
                </div>
                <br>
                <div class="form-group">
                    <label class="col-sm-3col-md-3col-lg-3 control-label" for="InputOrganization">Organization</label>
                    <div class="col-sm-4col-md-4col-lg-4">
                            <select name="select_Soshiki" class="form-control"ng-value="valueSoshiki"ng-model="select_Soshiki"ng-options="Soshikimenu.CD_Code1 as Soshikimenu.CD_Name for Soshikimenu in SoshikikiList;"
                            </select>
                    </div>
                    <div class="col-sm-2col-md-2col-lg-2">
                        <fontcoloer="red">${ErrOrganization}</font>
                </div>
                <br>
            </div>
            <div class="modal-footer modal-dialog-footer">
                <button type="button" class="btn btn-success"ng-click="modalSeikyusakiUpdate()">Register</button>
                <button type="button" class="btn btn-success"ng-click="$close()">Close</button>
            </div>
        </div>
    </body>
</script>

angularjs bootstrap spring tomcat

2022-09-29 22:45

1 Answers

After a lot of research, I was told that after Tomcat 5.X, Japanese characters will be garbled when getting them
See
http://ameblo.jp/spring-beginner/entry-10429339939.html
Therefore, I added the following items to the following parameters of server.xml on the server side (in my case, TOMCAT7 for Eclipse testing) and it was cured.

<Connector acceptCount="100" connectionTimeout="20000" 
 disableUploadTimeout="true" enableLookups="false" 
 maxHttpHeaderSize="8192" maxSpareThreads="75" maxThreads="150" 
 minSpareThreads="25" port="8080" redirectPort="8443"
useBodyEncodingForURI="true"<==Add this
 /> 

However, this time it's a little different because it's POSTed from the modal screen, but by the way
For POST, the following parameters are included in the web.xml.

<!--Character code support -->
    <filter>
        <filter-name>characterEncodingFilter</filter-name>
        <filter-class>
        org.springframework.web.filter.CharacterEncodingFilter
        </filter-class>
        <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>characterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>


2022-09-29 22:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.