These two days in the integration of the three framework when the STRUTS2 URL forwarding garbled problem, engaged in a long time also on the Internet to check a lot of information, write a filter, changed the configuration, all useless. Can only use the simplest form of violence, manual conversion garbled. because the editor starts with the default encoding of Iso-8859-1, the iso-8859-1 is converted to Utf-8.
General garbled problem, first check whether the database encoding is corresponding, the general installation of the database when the default encoding, if not set to Utf-8, add Chinese may appear garbled---can only modify the configuration or reload the database (this is not the focus of Ben Boven). Check the database, and then verify that the page encoding is consistent, if not solve the garbled problem, try to add Chinese test in the action layer, if there is no problem, it is Strust2 forwarding time into garbled. The solution is violent and simple.
Cases:
On the action layer:
Public String Execute () throws Unsupportedencodingexception
{
Title U=new title ();
U.setname (New String (Name.getbytes ("iso-8859-1"), "Utf-8"));
U.settype (New String (Type.getbytes ("iso-8859-1"), "Utf-8"));
U.setcondi (New String (Condi.getbytes ("iso-8859-1"), "Utf-8"));
U.setintro (New String (Intro.getbytes ("iso-8859-1"), "Utf-8"));
U.setorigin (New String (Origin.getbytes ("iso-8859-1"), "Utf-8"));
SimpleDateFormat df=new SimpleDateFormat ("Yyyy-mm-dd");
U.setdate (Df.format (New Date ()));
U.setgname ("Miss Chen");
U.setidea ("The subject is grey");
s.settitle_id (U);
Tmanager.add (U);
Smanager.update (s);
Return "Success";
}
No need to think through the brain, do not understand the forwarding mechanism, easy to solve garbled,
Three frames (SSH) About URL forwarding garbled problem (a solution to the simplest violence)