Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JSP¡¢Struts±ÜÃâFormÖظ´Ìá½»µÄ¼¸ÖÖ·½°¸

1 javascript £¬ÉèÖÃÒ»¸ö±äÁ¿£¬Ö»ÔÊÐíÌá½»Ò»´Î¡£



2 »¹ÊÇjavascript£¬½«Ìá½»°´Å¥»òÕßimageÖÃΪdisable

onsubmit="getElById('submitInput').disabled = true; return true;">


3 ÀûÓÃstrutsµÄͬ²½ÁîÅÆ»úÖÆ
ÀûÓÃͬ²½ÁîÅÆ£¨Token£©»úÖÆÀ´½â¾öWebÓ¦ÓÃÖÐÖظ´Ìá½»µÄÎÊÌ⣬StrutsÒ²¸ø³öÁËÒ»¸ö²Î¿¼ÊµÏÖ¡£
»ù±¾Ô­Àí£º
·þÎñÆ÷¶ËÔÚ´¦Àíµ½´ïµÄÇëÇó֮ǰ£¬»á½«ÇëÇóÖаüº¬µÄÁîÅÆÖµÓë±£´æÔÚµ±Ç°Óû§»á»°ÖеÄÁîÅÆÖµ½øÐбȽϣ¬¿´ÊÇ·ñÆ¥Åä¡£ÔÚ´¦ÀíÍê¸ÃÇëÇóºó£¬ÇÒÔڴ𸴷¢Ë͸ø¿Í»§¶Ë֮ǰ£¬½«»á²úÉúÒ»¸öеÄÁîÅÆ£¬¸ÃÁîÅƳý´«¸ø¿Í»§¶ËÒÔÍ⣬Ҳ»á½«Óû§»á»°Öб£´æµÄ¾ÉµÄÁîÅƽøÐÐÌæ»»¡£ÕâÑùÈç¹ûÓû§»ØÍ˵½¸Õ²ÅµÄÌá½»Ò³Ãæ²¢ÔÙ´ÎÌá½»µÄ»°£¬¿Í»§¶Ë´«¹ýÀ´µÄÁîÅƾͺͷþÎñÆ÷¶ËµÄÁîÅƲ»Ò»Ö£¬´Ó¶øÓÐЧµØ·ÀÖ¹ÁËÖظ´Ìá½»µÄ·¢Éú¡£
if (isTokenValid(request, true)) {
// your code here
return mapping.findForward("success");
} else {
saveToken(request);
return mapping.findForward("submitagain");
}
Struts¸ù¾ÝÓû§»á»°IDºÍµ±Ç°ÏµÍ³Ê±¼äÀ´Éú³ÉÒ»¸öΨһ£¨¶ÔÓÚÿ¸ö»á»°£©ÁîÅƵģ¬¾ßÌåʵÏÖ¿ÉÒԲο¼TokenProcessorÀàÖеÄgenerateToken()·½·¨¡£
1. //ÑéÖ¤ÊÂÎñ¿ØÖÆÁîÅÆ,»á×Ô¶¯¸ù¾ÝsessionÖбêʶÉú³ÉÒ»¸öÒþº¬input´ú±íÁîÅÆ£¬·ÀÖ¹Á½´ÎÌá½»
2. ÔÚactionÖУº
//
// value="6aa35341f25184fd996c4c918255c3ae">
if (!isTokenValid(request))
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("error.transaction.token"));
resetToken(request); //ɾ³ýsessionÖеÄÁîÅÆ
3. actionÓÐÕâÑùµÄÒ»¸ö·½·¨Éú³ÉÁîÅÆ
protected String generateToken(HttpServletRequest request) {
HttpSession session = request.getSession();
try {
byte id[] = session.getId().getBytes();
byte now[] =
new Long(System.currentTimeMillis()).toString().getBytes();
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(id);
md.update(now


Ïà¹ØÎĵµ£º

jspºÍServlet¸÷×ÔÌصã

1. servletÊÇÔÚjavaÀïǶÌ×html,jspÊÇÔÚhtmlÀïÃæǶÌ×java,jspÐèÒªÏȱàÒë³Éservlet²ÅÄÜÖ´ÐÐ.
2. jsp×îÖÕ·­Òë³ÉservletÖ´ÐÐ.jspÈÝÒ×ÉÏÊֺͱàд¶øservletÐèÒª×Ô¼ºÊÖ¶¯±àÒë,ºÜÂé·³µÄ
3. servletÏÖÔÚ¸ü¶àÊdz䵱MVCÄ£ÐÍ¿ØÖÆÆ÷µÄ½ÇÉ«,ÓÉËü¸ù¾Ý¿Í»§µÄÇëÇó,À´¶¯Ì¬×éÖ¯·µ»ØÊý¾Ý»òÒ³ÃæµÄÖض¨Ïò,¶øJSPÖ»×öÏÔʾ(MVCÄ£ÐÍ,ÏÔʾ¿ØÖÆÄ£ÐÍ ÏÔ ......

JSP+MySqlµÄʱ¼ä´¦Àí

ºÜ¾ÃûÓÐÓÃMysqlÁË£¬·¢ÏÖССµÄʱ¼äÎÊÌâÒ²Óöµ½²»ÉÙÂé·³£¬ºÇºÇ
ËùÒÔ×ܽáһϣº
µÚÒ»ÖÖ:
Date time= new java.sql.Date(new java.util.Date().getTime());
µÚ¶þÖÖ:
java ÓÃPreparedStatementÀ´setDate,ÓÃÎʺŵÄÐÎʽ¸øÈÕÆÚÎʺŸ³Öµ
pstmt.setTimestamp(8, new Timestamp(System.currentTimeMillis()));  
pst ......

Jsp JavaBean ServletʵÏÖMVC ϸ΢ÎÊÌâ×¢Òâ!

ÔÚJspÖе÷ÓÃSerlvetÖÐÒѾ­´æ´¢ÁËÐÅÏ¢µÄ JavaBean.
ServletÖÐÒѾ­°ÑÊý¾Ý¿âµÄÐÅÏ¢±£´æµ½JavaBeanÖÐ,ÔÙ°ÑJavaBean±£´æµ½SessionÖÐ.
Jsp¿ªÊ¼µ÷ÓÃ:
<jsp:useBean id="key" type="ClassName" scope="Session" />
<jsp:getProperty name="key" property="PropertyName" />
ÎÞ·¨¶Á³öÐÅÏ¢:
Ô­Òò: JavaBean ÖÐÊôÐÔµ ......

jsp ÍøÂç

 ÔÚtomcatÏÂÕÒµ½tomcat -> conf -> server.xml ÔÚÕâÒ»¾äÖÐÌí¼ÓºìÉ«²¿·Ö
<Connector connectionTimeout="20000" port="9090" protocol="HTTP/1.1" redirectPort="8443" useBodyEncodingForURI="true"
/> <!--URLEncoding=""--> ± ......

JSPÂÒÂëÖÕ¼«½â¾ö£¨ÊµÓã©

 JspÊÇÒ»¸öºÜÈÈÃŵĻ°Ì⣬µ«Èôó¶àÊýÈ˶¼Í·Í´µÄÊÇJSPÒ³ÃæÖеÄÂÒÂëÎÊÌ⣬±ÊÕßÉíÓÐÌå»á£»ÔøΪÁ˽â¾öÖÐÎÄÂÒÂëÎÊÌâÓôÃÆÁ˺ü¸Ì죬ÊÔÁ˺ܶ෽·¨¶¼²»ÐС£×îºóÔÚJSPרҵÈËÊ¿µÄ°ïÖúÏ£¬ÖÕÓÚ½â¾ö¡£Ö®ºó±ÊÕßÔø¶Ô´Ë×öÁËһЩСµÄÑо¿¡£  
  Ê×ÏÈÎÒÃÇÏÈÁ˽âÒ»ÏÂÎÊÌâµÄÔ­Òò¡£Ò»°ãÇé¿öÔÚÔÚÿ¸öJSPÒ³µÄÍ·²¿¶¼ÓÐÕâÑùÒ» ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ