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

JUnitѧϰ±Ê¼Ç15 ¶ÔJSPºÍtaglib½øÐе¥Ôª²âÊÔ2

ʹÓÃCactus¶Ôtaglib½øÐе¥Ôª²âÊÔ ÏÂͼÃèÊöÁËʹÓÃCactus¶Ô±ê¼Ç¿âµÄÒ»¸ö±ê¼Ç½øÐе¥Ôª²âÊԵĹý³Ì¡£(ͼƬÁ´½Ó) 1.Cactus¶ÔÏó³õʼ»¯²âÊÔÀ࣬¸ÃÀà±ØÐëÅÉÉú×ÔJspTestCaseÀ࣬²âÊÔ±ê¼ÇʱËùÐèÒªµÄÈκÎHTTP²ÎÊý£¬¶¼ÐèÒªÔÚbeginXXX·½·¨ÖнøÐÐÅäÖá£ÀýÈ磬Èç¹ûij±ê¼Ç´ÓHttp²ÎÊýÌáÈ¡ÐÅÏ¢£¬ÄÇôÄãÐèÒªÔÚbeginXXX·½·¨Öж¨Òå¸Ã²ÎÊý¡£ 2.ÔÚÄÚ²¿£¬CactusµÄJspTestCaseÀàµ÷ÓÃCactus JSP Redirector£¨±¾ÉíÒ²ÊÇÒ»¸öJSP£©¡£JSP Redirector¸ºÔðÔÚ·þÎñÆ÷¶Ë³õʼ»¯JspTestCaseÀ࣬´«ËÍJSPÒþʽ¶ÔÏó£¨Ö÷ÒªÊÇPageContext¶ÔÏ󣩸øËü¡£È»ºó£¬ÔÙµ÷ÓÃtestXXX·½·¨¡£ 3.ÔÚtestXXX·½·¨ÖУ¬±àд´úÂë¶ÔJSP±ê¼Ç½øÐе¥Ôª²âÊÔ¡£²âÊÔÒ»¸ö±ê¼ÇµÄµäÐͲ½ÖèΪ£ºÓÃnew ¶ÔÏó³õʼ»¯¸Ã±ê¼Ç£¬µ÷ÓÃsetPageContext£¬À´ÉèÖÃPageContext£¬µ÷ÓòâÊÔ·½·¨½øÐвâÊÔ£¬È»ºóÖ´ÐзþÎñ¶ËµÄ¶ÏÑÔ¡£ÀýÈ磬Èç¹û¸Ã±ê¼ÇÔÚHTTP¶ÎÖÐÉèÖÃÁËһЩ¶ÔÏó£¬Äã¾Í¿ÉÒÔ¶ÏÑÔÔÚÄÇÀï¡£ 4.Cactus JSP Redirector½«±ê¼ÇµÄÊä³öͨ¹ýHTTPÏìÓ¦·µ»Øµ½¿Í»§¶Ë¡£È»ºóÔÚJspTestCaseÀà±àдһ¸öendXXX·½·¨À´¶ÏÑÔ±ê¼ÇµÄÊä³ö¡£CactusÌṩÁËͬHttpUnitµÄ½ôÃܼ¯³É£¬Ëü½«ÔÊÐíÄã¶Ô·µ»ØµÄ±ê¼ÇÄÚÈݶ¨Ò徫ȷµÄ¶ÏÑÔ¡£ ¶¨Òå×Ô¶¨Òå±ê¼Ç ÔÚ½á¹ûÊÓͼÖУ¬ÎÒÃÇʹÓõĵÚÒ»¸ö±ê¼ÇÀཫÊÇDynaPropertiesTag¡£Õâ¸ö±ê¼Ç´ÓDynaBean¶ÔÏóÖÐÈ¡³öËùÓõÄÊôÐԷŵ½Ò»¸öÊý×éÀï¡£ÕâЩÊôÐÔ¶¼ÊÇDynaPropertyµÄ¶ÔÏ󣬴æ·ÅÔÚPageContextÖеÄÒ»¸öÁ¬½Óµ½±ê¼ÇµÄĿ¼Ï¡£ÏÂÃæÊǸñê¼ÇµÄÓ÷¨£º
ÆäÖÐproperties±íʾDynaProperty¶ÔÏóÊý×éµÄ±äÁ¿Ãû£¬dynaBeanÊÇÓÃÀ´»ñÈ¡ÊôÐÔÐÅÏ¢µÄDynaBeanʵÀý¡£
DynaProoertiesTagÈçÏ£º
package junitbook.pages;
import org.apache.commons.beanutils.DynaBean;
import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspException;
public class DynaPropertiesTag extends TagSupport
{
private String varName;
private String item;
public void setVar(String varName)
{
this.varName = varName;
}
public String getVar()
{
return this.varName;
}
public void setItem(String item)
{
this.item = item;
}
public String getItem()
{
return this.item;
}
public int doStartTag() throws JspException
{


Ïà¹ØÎĵµ£º

°ÑJSP·Åµ½WEB INFºóÒÔ±£»¤JSPÔ´´úÂë

    °ÑÄÇЩÏÞÖÆ·ÃÎʵÄ×ÊÔ´£¨±ÈÈç˵jspÔ´´úÂ룩·Åµ½WebÓ¦ÓõÄWEB-INFĿ¼Ï£¬¶ÔÓÚ/web-INF/¼°Æä×ÓĿ¼£¬²»ÔÊÐíÖ±½ÓµÄ¹«¹²·ÃÎÊ£¬ËùÒԾͿÉÒÔÆðµ½±£»¤ÕâЩ´úÂëδ¾­ÊÚȨµÄ·ÃÎʺͿúÊÓ£¬¸üºÃµÄ±£»¤ÁËÔ´´úÂë¡£
    ͨ³£JSP¿ª·¢ÈËÔ±»á°ÑËûÃǵÄÒ³ÃæÎļþ´æ·ÅÔÚWebÓ¦ÓÃÏàÓ¦µÄ×ÓĿ¼Ï¡£ÕâÖÖ·½·¨µÄÎÊÌâÊÇ ......

´«ÖDz¥¿Í——JSP(¶þ)ÄÚÖöÔÏó


Ò».request¶ÔÏó
   ¿Í»§¶ËµÄÇëÇóÐÅÏ¢±»·â×°ÔÚrequest¶ÔÏóÖУ¬Í¨¹ýËü²ÅÄÜÁ˽⵽¿Í»§µÄÐèÇó£¬È»ºó×ö³öÏìÓ¦¡£ËüÊÇHttpServletRequestÀàµÄʵÀý¡£
   µ±request¶ÔÏó»ñÈ¡Óû§Ìá½»µÄºº×Ö×Ö·ûʱ£¬»á²úÉúÂÒÂ룬ÓÉÏÂÃæµÄ·½·¨¿ÉÒÔ½â¾ö£º
¡¡¡¡ Sting s2 = new String(s1.getBytes("iso8859-1"),"GB2312") ......

JSP WEBServerµÄʵÏÖÔ­Àí

ÒòΪҪʵÏÖÒ»¸öWebServer£¬Ð´ÍêÁËÒ»¸ö¼òµ¥µÄWebServerºóÍ»·¢ÆæÏ룬ºÎ²»ÊµÏÖÒ»¸öJSP µÄWebServerÄØ£¿
ÓÐÁËÕâ¸öÏë·¨ºó£¬¾Í¿ªÊ¼¿¼ÂÇJSPµÄʵÏÖÔ­Àí£¬ÆäʵJSPµÄʵÏÖÒ²ºÜ¼òµ¥£¬Ëµ°×Á˾ÍÊǽ«Æäת»»³ÉÒ»¸öJavaÎļþ£¬ÔÙ¶ÔÕâ¸öJavaÎļþ½øÐбàÒ룬Éú³ÉÀàÎļþ£¬½Ó×ÅÔÙÓÉ·þÎñÆ÷ʹÓÃÕâ¸öÀàÎļþ¡£´Ó×ÜÌåÉÏ·Ö£¬¿ÉÒÔ½«JSPÎļþµÄÄÚÈÝ»®·ÖΪÁ½ ......

JSPÈëÃÅ

JSP¿ª·¢ÈëÃÅ
 
¸ÅÊö£º
JSP(Java Server Pages)ÊÇÓÉSun Microsystems¹«Ë¾³«µ¼¡¢Ðí¶à¹«Ë¾²ÎÓëÒ»Æð½¨Á¢µÄÒ»ÖÖ¶¯Ì¬ÍøÒ³¼¼Êõ±ê×¼¡£JSP¼¼ÊõÓеãÀàËÆASP¼¼Êõ£¬ËüÊÇÔÚ´«Í³µÄÍøÒ³HTMLÎļþ(*.htm,*.html)ÖвåÈëJava³ÌÐò¶Î(Scriptlet)ºÍJSP ±ê¼Ç(tag)£¬´Ó¶øÐγÉJSPÎļþ(*.jsp)¡£ ÓÃJSP¿ª·¢µÄWebÓ¦ÓÃÊÇ¿çƽ̨µÄ£¬¼ÈÄÜÔÚLinuxÏÂÔ ......

JSPʵÏÖ¼òÒ×µÄSQL±¨±í

ÊäÈë: select ID as ±àºÅ, NAME as ÐÕÃû, AGE as ÄêÁä from XXX
Êä³ö:
񅧏
ÐÕÃû
ÄêÁä
 
 
 
ÒªÇóÊÇÈç¹ûSQL±ä¶¯, ÈÔȻҪÏÔʾ³öÀ´ËùÓеıðÃû×Ö¶ÎÐÅÏ¢ºÍÊý¾Ý.
ÒòΪÏÖÔÚHibernateÓõıȽϹ㷺, ËùÒÔÓÅÏÈ¿¼ÂÇÓÃHibernateÀ´ÊµÏÖ, ½á¹û·¢ÏÖÈç¹ûÊÇʵÌåÓ³Éä²éѯÓï¾ä, ¿ÉÒÔ·½±ãµÄÓÃ:List<String> Quer ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ