Dear Struts users.
It reports because it investigated a little more.
When StrutsPrepareAndExecuteFilter is used, the value passed with POST in
GET at the end of the passed value , is handed over by switching off the
district.
Isn't does not it investigate with RFC
when the same value is handed over with POST after the value is passed with
GET,
it nor correct operation that only the value of POST is handed over?
Moreover, the operation of the METHOD type was investigated with processing
in ValueStack.
When GET is processed, it is stored with ISO-8859-1.
When POST is processed, it is stored with UTF-8.
Therefore, when the value is acquired with GET, it is necessary to convert
it into UTF-8 from ISO-8859-1.
However, ISO-8859-1 in POST afterwards + It becomes UTF-8. The sufficient
result cannot be obtained.
It devised, and I assumed to the value handed over I evaded this problem.
Thank you.
2010年7月3日18:23 kou kou...@gmail.com:
I've create GET method action Page with apache struts 2.1.8.1.
I'm making a page in encoding UTF-8.
struts action is setter value.
POST method 's setter value is encoding UTF-8.
but
GET method 's value is encoding ISO-8859-1.
This trouble resolved this Action setter.
but When GET was performed and went on POST.
The value is Incomplete.
Fundamentally, would there be a way to correct a change in a character
string besides this way?
web.xml:
filter-class
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
/filter-class
java :
action:
public class SampleAction extends ActionSupport{
public String execute(){return SUCCESS;}
public void setData(String data){
if(ServletActionContext.getRequest().getMethod().equals(GET)){
try {
this._data = StringUtils.encoding(data);
} catch (UnsupportedEncodingException e) {
}
}else{
this._data = data;
}
}
public String getData(){return _data;}
}
class:
public class StringUtils {
static public String encoding(String str) throws
UnsupportedEncodingException {
return new
String(str.getBytes(ServletActionContext.getResponse().getCharacterEncoding()),ServletActionContext.getRequest().getCharacterEncoding());
}
}
jsp Page:
%@ page language=java contentType=text/html; charset=UTF-8
pageEncoding=UTF-8%
!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
http://www.w3.org/TR/html4/loose.dtd;
html
body
GET form method=GET
input name=data value=日本語/
input type=submit /
/form
POST form method=POST
input name=data value=日本語/
input type=submit /
/formbr /
s:property value=data/
/body
/html
thank you.
--
kou kou...@gmail.com