Hibernate 模糊查询中文乱码:项目中使用的各种编码都是UTF-8 ,JSP、Myeclipse、xml、属性配置文件,等。后台输出Hibernate语句如下:

 

 
  
  1. Hibernate: select orderinstr0_.id as id3_, orderinstr0_.userId1 as userId2_3_, 
  2. orderinstr0_.instrumentName as instrume3_3_, orderinstr0_.instrumentDescription as instrume4_3_, orderinstr0_.userId2 as userId5_3_, orderinstr0_.specification as specific6_3_, 
  3. orderinstr0_.instrumentAddr as instrume7_3_, orderinstr0_.manufacturer as manufact8_3_, orderinstr0_.status as status3_, 
  4. orderinstr0_.instrumentPic as instrum10_3_, orderinstr0_.reservationInformation as reserva11_3_, 
  5. orderinstr0_.SchInPrice as SchInPrice3_, orderinstr0_.SchOutnPrice as SchOutn13_3_, orderinstr0_.price as price3_, 
  6. orderinstr0_.buyTime as buyTime3_, orderinstr0_.enableSTime as enableS16_3_, 
  7. orderinstr0_.enableETime as enableE17_3_, orderinstr0_.enableTime as enableTime3_, 
  8. orderinstr0_.serviceFor as serviceFor3_ from orderSys.dbo.order_instrument orderinstr0_ where orderinstr0_.instrumentName like '%??????%' <!--此处获取的是乱码-->

查找了半天,后来仔细一看,发现没有写method方法!如果没有写method,那么form默认的值就是 method="get".
 

 
  
  1. <form action="/OrderSys/instrument/morelikelist.action" 
  2.                             theme="simple" method="get"><!-- method不写乱码 \改成get也是乱码,默认就是get--> 
  3.                         <input id="searchContent" name="d" type="text" 
  4.                                 class="input_border" value="输入名称或型号..." size="25" 
  5.                                 onfocus="this.value=''" /> 
  6.                         <select id="leixing" name="s" class="input_border" 
  7.                                 style="height: 20px; padding-top: 2px;"> 
  8.                         <option value="instrumentName"> 
  9.                             仪器名称  
  10.                                 </option> 
  11.                         <option value="specification"> 
  12.                             仪器型号                            
  13. </option>                       </select>                         
  14.   <input style="cursor: pointer;" name="" type="button" id="tijiao" 
  15.                                 value="" onclick="this.blur();submit();" /> 
  16.                         </form> 

关于get 和 post 的区别:请google.