プロが教えるわが家の防犯対策術!

カスタムタグでパラメータから取得した日本語の文字化けを解決できません。
実行しているのは以下のソースです。

test.java

package test;
public class test extends javax.servlet.jsp.tagext.TagSupport{

private static final long serialVersionUID=1L;
private String testStr;
public void setTestStr(String testStr){
this.testStr=testStr;
}

//タグの開始時に実行されるメソッド
public int doStartTag() throws javax.servlet.jsp.JspException{
try{
response.setContentType("text/html;charset=UTF-8");
pageContext.getOut().write(new String(this.testStr.getBytes("8859_1"),"JISAutoDetect"));
}catch(java.io.IOException e){
throw new javax.servlet.jsp.JspException(e.getMessage());
}
return SKIP_BODY;
}
}

test.jsp

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="custom" prefix="custom"%>
<html>
<head><title>test</title></head>
<body>
<custom:test testStr="${param.test}" />
</body>
</html>

どのようにすれば解決できるでしょうか。

A 回答 (1件)

> pageContext.getOut().write(new String(this.testStr.getBytes("8859_1"),"JISAutoDetect"));



"JISAutoDetect"じゃなく"UTF-8"とか。
    • good
    • 0
この回答へのお礼

そのあたりを色々変えて試してみたところ解決しました。
ありがとうございます。

お礼日時:2008/09/18 13:11

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!