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
Ïà¹ØÎĵµ£º
document.getElementById("flag")ÔÚieÖУ¬jspÖеÄÔªËØûÓÐidÖµ£¬ÓÐnameֵʱ£¬Ò²Äܲé³öÀ´£¬°´ÕÕnameÖµ²é¡£
µ«ÊÇÔÚfirefoxÖУ¬Èç¹ûûÓÐidÖµ£¬Ôò²é²»³öÀ´¡£ËùÒÔieÖУ¬nameºÍidÓÐʱͨÓ㻵«ÊÇfirefoxÖУ¬ÊÇÓÐÕâÑϸñÇø±ðµÄ¡£ ......
ÔÚ±¾ÆªÎÄÕÂÖÐ,ÎÒÃǽ«»áÉîÈëÁ˽âÔÚ²»Í¬µÄTag LibraryÃèÊö·û(Tag Library Descriptors:TLDs)ÖÐʹÓø÷ÖÖ²»Í¬µÄtagµÄÇé¿ö.ÎÒÃǽ«»áÒÀ´ÎÑо¿ Ìõ¼þ¡¢Ñ»·¡¢URL¡¢U18N¡¢XMLµÈtagµÄÓ÷¨¡£ÒÔ´ËÀ´Ìá¸ßÄã¶ÔJSTLµÄÈÏʶºÍÓ¦ÓÃÄÜÁ¦,ÔÚÔĶÁ±¾ÎÄÇ°£¬ÄãÓ¦¸Ã¶Ô JSP Tag LibÓÐËùÁ˽⣬²¢ÇåÎúÓйØJSTL£¨JSP Standard Tag Libraries£©µÄ»ù± ......
ÔÚtomcatÏÂÕÒµ½tomcat -> conf -> server.xml ÔÚÕâÒ»¾äÖÐÌí¼ÓºìÉ«²¿·Ö
<Connector connectionTimeout="20000" port="9090" protocol="HTTP/1.1" redirectPort="8443" useBodyEncodingForURI="true"
/> <!--URLEncoding=""--> ± ......
JspÊÇÒ»¸öºÜÈÈÃŵĻ°Ì⣬µ«Èôó¶àÊýÈ˶¼Í·Í´µÄÊÇJSPÒ³ÃæÖеÄÂÒÂëÎÊÌ⣬±ÊÕßÉíÓÐÌå»á£»ÔøΪÁ˽â¾öÖÐÎÄÂÒÂëÎÊÌâÓôÃÆÁ˺ü¸Ì죬ÊÔÁ˺ܶ෽·¨¶¼²»ÐС£×îºóÔÚJSPרҵÈËÊ¿µÄ°ïÖúÏ£¬ÖÕÓÚ½â¾ö¡£Ö®ºó±ÊÕßÔø¶Ô´Ë×öÁËһЩСµÄÑо¿¡£
Ê×ÏÈÎÒÃÇÏÈÁ˽âÒ»ÏÂÎÊÌâµÄÔÒò¡£Ò»°ãÇé¿öÔÚÔÚÿ¸öJSPÒ³µÄÍ·²¿¶¼ÓÐÕâÑùÒ» ......
×î½ü×öÁËÒ»¸ö×ʷѲéѯģ¿é£¬ÀïÃæÉæ¼°½«×Ê·ÑÐÅÏ¢µ¼³öWordÎĵµºÍExcelÎĵµ£¬
ÏÈ˵˵µ¼³öWordÎĵµ£º
Æäʵ¾ÍÊÇ°ÑÏìÓ¦µÄÀàÐÍÉèΪapplication/msword,È»ºó°ÑÄÚÈÝÊä³öµ½Õâ¸öÎļþ¾ÍÐÐÁË
µÚÒ»²½£º
ÏÈÔÚ×ÀÃæÉÏн¨Ò»¸öwordÎĵµ,Ë«»÷´ò¿ª£¬È»ºóÁí´æΪ.htmÎļþ£¬»á²úÉúÒ»¸öÒÔ.htm½áβµÄÎļþ
µÚ¶þ²½£º
°Ñ.htmÎļþÀ©Õ¹Ãû¸ÄΪ.jspÎļ ......