mysql 질문입니다..
조회수 1528회
<select id="languageList" parameterType="java.util.HashMap" resultType="java.util.HashMap">
select bs.*
from (
select
@rownum:=@rownum+1 as row_num
,go_code
, go_name
, co_code
, co_name1
, co_name2
, langGbn
, cnt
from (
select
go_code
, go_name
, co_code
, co_name1
, co_name2
, a.langGbn
, ifnull(cnt,0) as cnt
from (
select
go_code
, go_name
, co_code
, co_name1
, co_name2
, langGbn
, langSort
from ts_gov_code a, (
select
a.co_code
, ifnull(b.co_name,a.co_name) as co_name1
, a.co_name as co_name2
from ts_code a
left join ts_code b on a.co_up_code=b.co_code
where a.co_up_code like 'ST%'
and a.co_val1 != 'type'
and a.co_code not in ('ST01','ST02')
<if test="type_code != null and type_code != '' ">
and a.co_code like concat(#{type_code},'%')
</if>
) b
, (
select '한' as langGbn, 1 langSort
union
select '한.영' as langGbn, 2 langSort
union
select '한.중' as langGbn, 3 langSort
union
select '한.일' as langGbn, 4 langSort
union
select '한.영.중' as langGbn, 5 langSort
union
select '한.영.일' as langGbn, 6 langSort
union
select '한.중.일' as langGbn, 7 langSort
union
select '한.영.중.일' as langGbn, 8 langSort
) c
where a.go_use_yn = 'Y'
<if test="(go_code != null and go_code != '') or go_code == '36' ">
<if test="go_code != '36'">
and a.go_gbn = 'G'
</if>
and substr(a.go_code,1,2) = #{go_code}
</if>
<if test="(go_code == null or go_code == '') and go_code != '36' ">
and a.go_gbn = 'S'
</if>
) a
left join (
select
<if test="(go_code != null and go_code != '') or go_code == '36' ">
si_go_code
</if>
<if test="(go_code == null or go_code == '') and go_code != '36' ">
substr(si_go_code,1,2) as si_go_code
</if>
, si_type_code
, langGbn
, count(*) as cnt
from (
select
si_go_code
, si_type_code
, case when si_ko_yn = 'Y' and si_en_yn != 'Y' and si_ch_yn != 'Y' and si_jp_yn != 'Y' then '한'
when si_ko_yn = 'Y' and si_en_yn = 'Y' and si_ch_yn != 'Y' and si_jp_yn != 'Y' then '한.영'
when si_ko_yn = 'Y' and si_en_yn !='Y' and si_ch_yn = 'Y' and si_jp_yn != 'Y' then '한.중'
when si_ko_yn = 'Y' and si_en_yn != 'Y' and si_ch_yn != 'Y' and si_jp_yn = 'Y' then '한.일'
when si_ko_yn = 'Y' and si_en_yn = 'Y' and si_ch_yn = 'Y' and si_jp_yn != 'Y' then '한.영.중'
when si_ko_yn = 'Y' and si_en_yn = 'Y' and si_ch_yn != 'Y' and si_jp_yn = 'Y' then '한.영.일'
when si_ko_yn = 'Y' and si_en_yn != 'Y' and si_ch_yn = 'Y' and si_jp_yn = 'Y' then '한.중.일'
when si_ko_yn = 'Y' and si_en_yn = 'Y' and si_ch_yn = 'Y' and si_jp_yn = 'Y' then '한.영.일.중'
else '기타' end langGbn
from ts_sign
where si_del_yn != 'Y'
<if test="type_code != null and type_code != '' ">
and si_type_code like concat(#{type_code},'%')
</if>
<if test="(go_code != null and go_code != '') or go_code == '36' ">
and substr(si_go_code,1,2) = #{go_code}
</if>
) sub
<if test="(go_code != null and go_code != '') or go_code == '36' ">
group by si_go_code, si_type_code, langGbn
</if>
<if test="(go_code == null or go_code == '') and go_code != '36' ">
group by substr(si_go_code,1,2), si_type_code, langGbn
</if>
) b on b.si_go_code=a.go_code and b.si_type_code=a.co_code and b.langGbn=a.langGbn
order by go_code desc, co_code desc, langSort desc
) tt, (select @rownum:=0) tmp
) bs
order by row_num desc
limit #{from_record},#{page_size}
<!-- <![CDATA[
where rownum < #{from_record} + #{page_size} + 1
]]>
)
where rnum > #{from_record} -->
</select>
위와같이 xml 맵퍼 sql 문중
select '한' as langGbn, 1 langSort
union
select '한.영' as langGbn, 2 langSort
union
select '한.중' as langGbn, 3 langSort
union
select '한.일' as langGbn, 4 langSort
union
select '한.영.중' as langGbn, 5 langSort
union
select '한.영.일' as langGbn, 6 langSort
union
select '한.중.일' as langGbn, 7 langSort
union
select '한.영.중.일' as langGbn, 8 langSort
이부분을 받아서 웹상에 출력하면 한글이 깨지는 현상이 발생합니다.ㅜ 영어는 잘 출력되고요 ㅜ
�븳
�븳.�쁺
....
....
인코딩은 다 UTF-8 로 했고요 ㅜ
3 답변
-
우선 xml 파일에 다음과 같이 인코딩을 지정해보세요.
<?xml version="1.0" encoding="UTF-8"?>
그리고, java compile할 때에도 인코딩이 UTF-8로 제대로 지정되어 있는지 확인해보시구요.
-
(•́ ✖ •̀)
알 수 없는 사용자
- xml에서는 지정되어 있고요 스트러츠2모델이고요 자바단에서 문제가 있는듯한데 스트러츠2모델이 처음이라 어렵네요 ㅜ 김영광 2016.6.21 19:35
- 다른 데이터는 다 정상적으로 출력되는데 ``` select '한' as langGbn, 1 langSort union select '한.영' as langGbn, 2 langSort union select '한.중' as langGbn, 3 langSort union select '한.일' as langGbn, 4 langSort union select '한.영.중' as langGbn, 5 langSort union select '한.영.일' as langGbn, 6 langSort union select '한.중.일' as langGbn, 7 langSort union select '한.영.중.일' as langGbn, 8 langSort ``` 이렇게 가져온 문자열만 출력이 그러네요 ㅜ 김영광 2016.6.21 19:41
-
-
다른 데이터는 다 정상적으로 출력되는데
select '한' as langGbn, 1 langSort union select '한.영' as langGbn, 2 langSort union select '한.중' as langGbn, 3 langSort union select '한.일' as langGbn, 4 langSort union select '한.영.중' as langGbn, 5 langSort union select '한.영.일' as langGbn, 6 langSort union select '한.중.일' as langGbn, 7 langSort union select '한.영.중.일' as langGbn, 8 langSort
이렇게 가져온 문자열만 출력이 그러네요 ㅜ -
JDBC Connection 설정을다음과 같이 해보셨나요?
jdbc:mysql://<HOST>/<DB>?useUnicode=true&characterEncoding=utf8
useUnicode=true
: 서버와 연결에서 유니코드를 사용하고characterEncoding=utf8
: 문자셋을 utf8로 사용함을 선언
혹은 서버의 설정에서 mysql client 문자셋의 기본값을 utf8로 변경한 후에 다시 해보세요.
댓글 입력