It can be said that every independent solution to a problem is a great encouragement and encouragement to me, making me more confident! Looking at the problems solved one by one, I took a sigh of relief !!!
Today, two more problems have been solved:
1. the problem of Chinese garbled characters is similar to the method of learning JSP to solve Chinese garbled characters when using SSH framework integration. I use struts1. Of course, if struts2 is used, it seems better to solve the problem. You can simply use the filter and configure it yourself. In struts1, I solve Chinese garbled characters like this:
1) Write a processing class first:
Package com. Struts. processor; (custom package name)
Import java. Io. unsupportedencodingexception;
Import javax. servlet. http. httpservletrequest;
Import javax. servlet. http. httpservletresponse;
Import org. Apache. Struts. Action. requestprocessor;
Public class newprocessor extends requestprocessor {
Protected Boolean processpreprocess (httpservletrequest arg0,
Httpservletresponse arg1 ){
Try {
Arg0.setcharacterencoding ("GBK"); ----> of course, the encoding format can be customized.
} Catch (unsupportedencodingexception e ){
E. printstacktrace ();
}
Return super. processpreprocess (arg0, arg1 );
}
2) Configure in struts-config.xml:
<Controller>
<Set-Property = "processorclass" (Object of A Class)
Value = "com. Struts. processor. newprocessor"/> (package name and class name)
</Controller>
Write it in front of the resource configuration file
3) the JSP pages and other pages must follow this principle. Here I set it to GBK, so the encoding format pages and configuration files involved must be changed to GBK.
2. Use hiberanate to encapsulate database operations. During the add operation, data is inserted, but at the same time, a blank row value is displayed:
1) To be honest, this mistake wastes a lot of time on me. I searched for it on Google. I didn't find it. I asked some netizens who also gave me a general explanation, it seems that you have to rely on yourself,
I firmly believe that I can do it myself. Even if the compensation should not be a waste of time, I should persistently look at, debug, and find the root cause of the error.
2) I used hibernate to manage data, so many database operations have been completed. So I went to its source file to see it, without any clue, the error cause cannot be found.
3) I tried a lot of methods and changed the code many times but failed to do so. Finally, this change solved the problem:
When the collected form data is uploaded to the action, first judge and limit it. If the data passed is empty, it will not be allowed to execute the following program, in this way, the transfer of NULL data can be solved and prevented. Ah, it was so simple !!