Jquery 数据表 使用特殊字符的服务器端处理 (Ex:äää)



我正在使用应用程序的数据表,我使用了服务器端分页[JSP-Struts-2],我在特殊字符搜索问题上浏览了不同的线程。无法弄清楚。常规的英语文本搜索效果很好。

请在下面找到我的代码。

$(document).ready(function(){
                        oTable = $('#example').dataTable({
                            "bJQueryUI": true,
                            "bPaginate": true,
                           "bServerSide": true,
                            "sAjaxSource": "ajaxUserSearch.action",
                            "bProcessing": true,
                                     "bLengthChange": false,                               
                            "oLanguage": {
                            "sUrl": '<s:text name="datatables.msgs"/>'
                                },
                                    "aoColumnDefs": [
       {
           "aTargets":[0],
           "fnCreatedCell": function(nTd, sData, oData, iRow, iCol)
           {
               $(nTd).css('text-align', 'center');
           },
           "mData": null,
           "mRender": function( data, type, full) {    // You can use <img> as well if you want
           //console.log(full[7]);
           if(full[7]=='ACTIVE' || full[7]=='Active')
                            {
                                return '<input type="radio" name="salesOrgSelection" onclick="setUsrId('+full[9]+',2)"  /> <td>';
                            }
                            else{
                                return '<input type="radio" name="salesOrgSelection" onclick="setUsrId('+full[9]+',1)"  /> <td>';
                            }
           },
            }
    ]
                        });
                                oTable.fnSetColumnVis( 9, false );
                    });

在server_processing.php中查找:

mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
    die( 'Could not select database '. $gaSql['db'] );

添加

//To send utf8 data to MySql - needed if you need to inject utf8 data for search
    mysql_query("SET character_set_client=utf8", $gaSql['link']);
    mysql_query("SET character_set_connection=utf8", $gaSql['link']);
//To read utf8 data from MySql - needed if your result set contains utf8 data
    mysql_query("SET character_set_results=utf8", $gaSql['link']);

最新更新