Ϊʲô > ÈçºÎ´ò¿ªjspÎļþ,myeclipseΪʲôûÓÐÔËÐÐjspÎļþ

ÈçºÎ´ò¿ªjspÎļþ,myeclipseΪʲôûÓÐÔËÐÐjspÎļþ

2020-10-19 15:00ÔĶÁ(62)

1¡¢´ò¿ªeclipse£¬file newÒ»¸ö¶¯ÍøÏîÄ¿¡£2ÈëÄãµÄÏîÄ¿Ãû³Æºó£¬µ¥»÷next£¬¹´Ñ £3¡¢´òÄ¿¿´ÓÐÒ»¸ö×Ô¶¯Éú³ÉµÄweb.xmlÓ³ÏñÎļþ¡£4¡¢ÖÁ´ËÅäÖÃÎļþºÃÁË£¬ËùÒÔÖ±½Óµã»÷Web

1

1¡¢´ò¿ªeclipse£¬file newÒ»¸ö¶¯ÍøÏîÄ¿¡£

2ÈëÄãµÄÏîÄ¿Ãû³Æºó£¬µ¥»÷next£¬¹´Ñ¡¡£

3¡¢´òÄ¿¿´ÓÐÒ»¸ö×Ô¶¯Éú³ÉµÄweb.xmlÓ³ÏñÎļþ¡£

4¡¢ÖÁ´ËÅäÖÃÎļþºÃÁË£¬ËùÒÔÖ±½Óµã»÷WebContentÓÒ¼ünewÒ»¸öjspÎļþ ÃüÃûΪindex.jsp¡£

5¡¢ index.jspÐèÒªÅäÖóÉUTF-8 »ògbk2312 ·ñÔòÎÞ·¨ÔËÐÐÖÐÎÄ×Ö·û´®¡£

6¡¢¿ÉÒÔÔÚÀïÃ涥һ¸öjspÒ³ÃæÄØ Ìì½¾java³ÌÐòÐèҪʹÓÃ<%%>ÔÚÈκÎÒ»¸öλÖö¼¿ÉÒÔ ¡£

7¡¢µ±È»ÕâЩ¶¼ÊÇ·þÎñÆ÷Õý³£ÔËÐеÄÇé¿öÏ £¬Èç¹ûTomcatûÓÐÅäÖúÃÄÇôÐèÒªÒÔϲ½Ö裺ÕÒµ½Serversµã»÷¡£

8¡¢Ñ¡Ôñtomcat²¢ÇÒÃüÃû ¡£

9¡¢TomcatÅäÖÃÍê³É¡£

-

ÏÂÃæÊǸü¶à¹ØÓÚÈçºÎ´ò¿ªjspÎļþµÄÎÊ´ð

tomcat ÔõôÔËÐÐjspÎļþ?

1.Èç¹ûÄãÖÃÐéÄâĿ¼,°ÑjspÎļþ·ÅÔÚwebapps\ROOTÏÂ,ÕâÊÇtomcatµÄ.

2.Èç¹ûÄã²»Ïë·ÅÔÚROOT϶øÏë·Åµ½Ä¿Â¼ÏÂ,ÄãÒªÊÖ¹¤½¨Ò»Îļþ¼Ð,¼ÙÉèÃûΪxxx,λÖÃÔÚDÅÌ,ÔÚxxxÏÂÄã¿ÉÒÔ½¨jspÎļþ,»¹±ØÐ뽨һ¸öWEB-INFµÄÎļþ¼Ð,

ÔÚWEB-INFÖÐÓÖÓÐÁ½¸öÊDZØÐëµÄ,·Ö±ðΪweb.xmlºÍlibÎļþ¼Ð,libÏ·ŵÄÊÇoracle,sqlserver»òmysqlµÄjar°ü,¾ÍÊÇÁ¬Êý¾Ý¿âʱҪÓõ½µÄjar°ü.

web.xmlµÄÄÚÈÝΪ:

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"

version="2.4">

</web-app>

ÄãÖ»Òª¸´ÖÆÕ³Ìù½øÈ¥¾Í¿ÉÒÔÁË.

Íê³ÉÉÏÃæµÄ²½Öè,×îºó¾ÍÒªÅäÖÃserver.xmlÁË,ÔÚ</HOST>µÄÉÏÃæÒ»ÐÐÌí¼ÓÒ»Ìõ<Context path="/aaa" docBase="D:\xxx">,ÆäÖÐ/ºóÃæµÄaaa¿ÉÒÔ×Ô¼ºËæ±ãÈ¡,docBaseΪÐéÄâĿ¼µÄ·¾¶.

Íê³ÉÉÏÊöÅäÖÃ,Äã¾Í¿ÉÒÔ×Ô¼ºÐ´Ò»¸öjspÎļþÊÔÊÔÁË,·ÃÎʵÄʱºòÏÈÔËÐÐtomcat,ºóÔËÐÐIEä¯ÀÀÆ÷,ÔÚµØÖ·À¸ÊäÈëhttp://localhost:8080/aaa/x.jsp,aaa¾ÍÊÇÉÏÃæÄã×Ô¼ºÆðµÄ,x.jsp¾ÍÊÇÄãдµÄjspÎļþ

»¹ÓÐÒ»µã,Èç¹ûÄã´úÂëûд´í,¶øÔËÐÐʱ·¢Éú´íÎó,¼ì²éÒ»ÏÂconf\web.xmlÖÐlisting,´ó¸ÅÔÚÆßÊ®¼¸ÐÐ,¼ì²éϸÃÐÐÏÂÃæµÄÖµÊÇ·ñΪtrue,Èç¹ûΪfalse,Çë°ÑËü¸ÄΪtrue.

ÎÒËù˵µÄÏ£Íû¶ÔÄãÓÐËù°ïÖú. ±¾»Ø´ð±»ÍøÓѲÉÄÉ

tomcatÖÐÔõôÔËÐÐhtmlºÍjsp°¡£¿

µÚÒ»²½½«htmljspÎļþ¿½±´µ½ÄãwebappsµÄrootĿ¼Ï£¨¼Ùa.jsp»òa.html£©£¬»òÕßÄãÉèÖõÄÐéÄâĿ¼ÏÂ

²½£ºtomcat·þÎñÆ÷

µÚÈý²½£º´ò¿ªä¯ÀÀÆ÷£¬ÔÚä¯ÀÀÆ÷ÊäÈ룺http://localhost:8080/a.jsp/

Ç°ÌáÊÇÄãµÄjava»·¾³±äÁ¿ºÍtomcat»·¾³±äÁ¿ÉèÖÃÕýÈ·

jspÔõôʹÓÃ.classÎļþ?tomcat

ÄãÒª×öµÄ½ö½öÊÇ2²½ºÇºÇ:

1.Äã±ØÐëÔÚÍøÕ¾µÄ¸ùϽ¨Á¢WEB-INFÎļþ¼Ð,È»ºóÔÚÀïÃ潨Á¢2¸öÎļþ¼Ð½ÐclassºÍlib,ÒÔ¼°Ò»¸öÎļþweb.xml

.×¢ÒâÎҵĴóСд.½¨Á¢ºÃºó,¿ªÊ¼·ÅÈëclassµÄÎļþ.Èç¹ûÄãµÄclassÒѾ­·â×°³ÉlibÁË,¾ÍÖ±½Ó·ÅÔÚlibÎļþ¼ÐÏÂ.Èç¹ûÊÇ.class,¾ÍÖ±½Ó°ÑWEB-INF\class×÷Ϊ°üµÄ¸ù·¾¶,°Ñclass·ÅÈëclassÎļþ¼Ð,±ÈÈçÎÒÓиöÀà MyClass.class,ÊÇ°üMyPacketÀïÃæµÄ,ÄÇôËýÓ¦¸Ã·ÅÔÚWEB-INF\class\MyPacket\ÀïÃæ.

2.ÔÚJSPÀïÃæ,Ê×ÏÈÔÚÒ³Ê×¼ÓÔØÏà¹ØµÄ°ü»òÕßÀà.ÀàËÆÏÂÃæ:

<%@ page import="MypPacket.MyClass,

MypPacket.MyClass2%>

»òÕß

<%@ page import="MypPacket.*"%>

Çø±ðÎҾͲ½ÓÃ˵Á˰ɺǺÇ.

È»ºóÔÚ´úÂëÄھͺܼòµ¥ÁË,ºÍjavaÒ»ÑùÁË.±ÈÈçµ÷Óú¯Êý:

<%

MyClass mc = new MyClass();

mc.getMyParameter();

%>

ÓùßÁËÄã»á·¢ÏÖ<JSP-BEAN>ÕâЩtagÊǶàôÓÞ´ÀµÄÉè¼ÆºÇºÇ.

----------------------------------------------

enjoy it~

myeclipseÈçºÎµ¥¶ÀÔËÐÐjspÎļþ

²Ù×÷²½ÖèÈçÏ£º

1¡¢ÓÒ¼üµã¹¤³Ì£­£­> myeclips£­£­> add or removte project dep£»

2¡¢ È»ºóÖ¸¶¨¸ö·þÎñÆ÷£¬È»ºóÔÚä¯ÀÀÆ÷ÖÐÊäÈëurl¾Í¿ÉÒÔÁË ¡£

apache2 +tomcat ÔõôÔËÐÐjsp

1¡¢Õâ¸öÊôÓÚapacheºÍtomcatÕûºÏ¡£

2ÀíÊÇʹtomcat´¦Àíj2ee¡£Ê¹ÓÃapache´¦ÀíÆäËûÇëÇó£¬Èçphp£¬×ÊÔ´µÈ¡£

3¡¢ÅäÖ㬽«tomcatapacheµÄÒ»¸öplugin£¬¿ªÄÚ²¿¶Ë¿Ú£¬±ÈÈç8080£¬apacheͳһ¼àÌý80¶Ë¿Ú£¬ÊÂÏÈÔÚÅäÖÃÎļþÀïÅäÖÃÇëÇóת·¢£¬±ÈÈç urlp:*.jsp£¬Òâζ×ŵ±jspµÄÇëÇóµ½À´µÄʱºò£¬apache²»´¦Àí£¬×ª·¢¸ø8080¶Ë¿ÚµÄtomcat´¦Àí£¬µ±tomcat´¦ÀíÍê³Éºó£¬½á¹ûÓÉ8080¶Ë¿Ú·µ»Ø¸øapache£¬È»ºóÔÙÓÉapache½«½á¹ûÓÉ80¶Ë¿Ú·µ»Ø¸øä¯ÀÀÆ÷¿Í»§¡£

4¡¢¾ßÌåÅäÖã¬ÍøÉÏËÑË÷ÏÂapacheÕûºÏ tomcat£¬Ã¿¸öÅäÖö¼ºÜÏêϸ£¬ÕâÀï¾Í²»ÁоÙÁË¡£ ×·ÎÊ
¶÷,Äã˵µÄÎÒ¶¼ÖªµÀ.¶øÇÒÎÒÒ²ÊÔ¹ý.¾ÍÊÇûÓÐÅäÖúÃ,²»ÖªµÀʲôÇé¿ö.
¶÷,Äã˵µÄÎÒ¶¼ÖªµÀ.¶øÇÒÎÒÒ²ÊÔ¹ý.¾ÍÊÇûÓÐÅäÖúÃ,²»ÖªµÀʲôÇé¿ö.
±¾»Ø´ð±»ÌáÎÊÕߺÍÍøÓѲÉÄÉ

Ïà¹ØÎÊ´ðÍƼö

Èȵã¹Ø×¢

Ó¡¶ÈΪʲô³·¾ü,Ó¡¶È³·¾üµÄÔ­Òò Ϊʲô¾Ù²»ÆðÀ´, ÏÌѼµ°ÎªÊ²Ã´»áÁ÷ÓÍ,ΪʲôÏÌѼ Ϊʲô˵ÄÏϱ±ÉÏ, Ϊʲô¶¼ËµÓ×ʦŮ¿ª·Å,Å®Éúµ±Ó× ²ÜÆÆÌìΪʲô±»·âºÅ,»¹ÓÐË­¼ÇµÃ »ÆϦ±¶ÎªÊ²Ã´½ÐÉñÆÅ, ˹ŵµÇΪʲôȥ±ùµº,˹ŵµÇΪʲ ÓÚÕýΪʲô±»´ò,À´²Â²ÂÓÚÕýΪʲ ÑîÖÂԶΪʲô´ÇÖ°, ÍÐÀ×˹Ϊʲô´÷Ãæ¾ß, Ϊʲô½ÐСÀû˹Éñ,СÀû˹ÉñÊÇʲ ÕÅÁ¦ÒüΪʲô±»Ñ©²Ø, ÓÅ¿ÍÀîÁÖΪʲô½âÉ¢, ÉÐÓÚ²©ÎªÊ²Ã´×Ôɱ,ÉÐÓÚ²©µÄ½éÉÜ ºÚgirlΪʲô½âÉ¢,sswÕ½¶ÓΪʲô 7ºÅΪʲôÀ뿪gtv,7ºÅΪʲôÀ뿪 ΪʲôŮÈË»á²Ù³öѪ,Å®ÉúÔ¾­¸Õ ÇñÆôÃ÷ΪʲôÀ뿪ÑëÊÓ,ÕÔÆÕÒòΪ ÑîîÚӨΪʲôҪ¸´³ö,¡°Ìð¸èÍõºó »¨ÖàΪʲôÍ˳öÂéÓÍÒ¶,ÂéÓÍÒ¶ÊÇ Âí¶«ÎªÊ²Ã´²»Ç©½ªË¼´ï, ФÑïΪʲôҪ×Ô¾¡,ФÑïÖ®ËÀÊÇÕ¦ ΪʲômsnµÇ½²»ÉÏ,ΪʲôÊÖ»úMS ɱÚäİΪʲô»á»ÙÈÝ,»¨Ç§¹Ç ɱÚä °¢Ä¡Ϊʲô×øÀÎ,2007Äê¿ìÄÐ13 Íõ·ÆΪʲôҪ³ö¼Ò,Íõ·Æ²»ÊÇÒª³ö ÀîÕØÐÇΪʲô±»ÃâÖ°,ÀîÕØÐǵ±¹ý ÉÁ¹â·ò¸¾ÎªÊ²Ã´Ï³µ, Ϊʲô˵ÑîÃÝÊǺÚľ¶ú,Ϊʲô˵