some ideas in the project1. The name of the database table should be capitalized, and the full meaning of the expression, with the underline separated, such as t_web_xxxxx_user. XXXXX here refers to the project name. The field name of the table can be the initials of the project with an underscore plus a specific meaningful name, such as Xx_userid, Xx_username ... It is highly recommended that you use rational rose when designing a database, which is easy to manage and maintain. 2. In struts, the path of the action is configured. If some projects are cyclical, some projects may be done this year, and next year, it is better to add the year before the path, such as: <action path= "/2006/xxx/user_add" type= " Com.web.xxx.action.UserAddAction ">
<forward name= "Success" Path= "/web-inf/jsp/2006/xxx/success.jsp" ></forward>
</action> 3. At present, to prepare for work, collect available resources, write design documents and flow charts, only when you have a spectrum in mind, you can consider the comprehensive, in the future even if there are errors in the project, you can first view the document and flowchart, and then check the code until the error is excluded.
Configure the Chinese character encoding in struts. When you configure Chinese character encoding in struts, you can write a class to inherit the Actionservlet class and overload the process method. 1. Import java.io.IOException;
Import javax.servlet.ServletException;
Import Javax.servlet.http.HttpServletRequest;
Import Javax.servlet.http.HttpServletResponse; Import Org.apache.struts.action.ActionServlet; public class Chinaredtea extends Actionservlet {private static final long serialversionuid = -995919609576385793l; Public Chinaredtea () {
} protected void process (HttpServletRequest request,
HttpServletResponse response) throws Servletexception, IOException {
Request.setcharacterencoding ("GB2312");
Super.process (request, response);
}
}
2. Modify the Web.xml file. <?xml version= "1.0" encoding= "UTF-8"?>
<web-app xmlns= "Http://java.sun.com/xml/ns/j2ee" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" version = "2.4" xsi:schemalocation= "Http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
<!--
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
--> <servlet>
<servlet-name>ChinaRedTea</servlet-name>
<servlet-class>com.chinaredtea.web.blog.actions.ChinaRedTea</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet> <servlet-mapping>
<servlet-name>ChinaRedTea</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping> <welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app> so you don't need to convert the Chinese character in the action class of the Web application. You can also configure some JSP pages to be action, so that the entire application does not have to deal with Chinese.
How to obtain the Chinese Unicode encoding/**
* For example: Ch is "Chinese", will get "/u4e2d/u6587"
*
* February 24, 2006.
*
* @param CH
* @return
*/
public static string Obunicode (String ch) {
if (ch = null | | ch.equals ("")) {
ch = "Chinese";
}
StringBuffer sb = new StringBuffer ();
for (int i = 0; i < ch.length (); ++i) {
Sb.append ("
//u "+ long.tohexstring (Ch.charat (i)));
}
return sb.tostring ();
}