ÔÚTomcatÖÐÅäÖÃServlet£¬Èç¹ûÒª¶ÔһЩServlet½øÐÐÇëÇ󷾶µÄÓ³Éäʱ£¬¿ÉÒÔʹÓÃ×¢½âµÄ·½Ê½À´ÊµÏÖ£¬ÕâÑù¿ÉÒÔ»º½âweb.xmlÎļþµÄѹÁ¦£¬±ÜÃâweb.xmlÎļþ¹ýÓÚÓ·Ö×£¬¼Ó¿ìÎļþµÄ½âÎöÌá¸ßTomcatÆô¶¯Ëٶȡ£
×¢½âËäºÃ£¬µ«Ò²Óпӡ£
ÎÒÃǶ¼ÖªµÀ£¬´ÓJavaEE6£¨Tomcat3£¬Servlet3.0£©¿ªÊ¼£¬Servlet²ÅÖ§³Ö×¢½âµÄÓ¦Óá£
ÔÚTomcat7֮ǰµÄ°æ±¾£¬Ä¬ÈϵÄÇé¿öÏ£¬Èç¹ûҪʹÓÃ×¢½âÀ´Ó³ÉäServlet£¬ÊÇÐèÒªÔÚweb.xmlÖпªÆô¶ÔServlet×¢½âµÄÖ§³Ö£¬ÕâÑùʹÓÃ×¢½âµÄ½øÐÐÓ³ÉäµÄʱºò²ÅÓÐЧ¹û£¬Êµ¼ÊµÄÇé¿öÊÇ£¬TomcatºöÂÔÁ˶ÔServletʵÌåÀàÉϵÄ×¢½âÓ¦Óá£
´ò¿ªweb.xmlÎļþ£¬¿ÉÒÔ¿´µ½ÕâÑùµÄÔ¼Êø£º
<?xmlversion="1.0"encoding="UTF-8"?> <web-appxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID"version="3.0">
</web-app> |
¶øʵ¼ÊÉÏ£¬ÕâÒ»¶ÎÔ¼ÊøÖУ¬»¹Òþ²ØÁËÕâôһ¸öÊôÐÔ£º
<?xmlversion="1.0"encoding="UTF-8"?> <web-appxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID"version="3.0"metadata-complete="true">
</web-app> |
û´í¹þ£¬µ¼ÖÂServlet×¢½âûÓÐЧ¹ûµÄ£¬¾ÍÊÇÕâ¸öÊôÐÔ£¬ËüµÄÒâ˼ÊǺöÂÔServletʵÌåÀàÉϵÄ×¢½â£¬²»È¥É¨ÃèÕâЩע½â£¬ËùÒԾͲ»Æð×÷Óá£
Èç¹ûʹÓÃÁË×¢½â¶øûÓÐÆðµ½ÈκεÄЧ¹û£¬ÔÚ±£Ö¤ServletÄÜÔÚweb.xmlÖÐÕý³£Ö´ÐеÄÇ°ÌáÏ£¬ºÜ´óµÄ¿ÉÄܾÍÊÇÒòΪûÓпªÊ¼¶Ô×¢½âµÄÓ¦Óá£
ÈçºÎ¿ªÊ¼¶ÔServlet×¢½âµÄÓ¦ÓÃÄØ£¿
Ö»ÐèÒª°Ñmetadata-completeÊôÐÔµÄÖµÉèÖÃΪfalse¾Í¿ÉÒÔÁË£¬ÈÃTomcat²»ºöÂÔServletʵÌåÀàµÄ×¢½â¾Í¿ÉÒÔÁË¡£
ÁíÍâ²»µÃ²»ÌáµÄÒ»µã£¬µ½ÁËTomcat7ÒÔºóµÄ°æ±¾£¬¸ÄΪÁËĬÈÏÇé¿öÏÂÊÇÖ§³ÖServlet×¢½âÓ¦Óõġ£µ±È»£¬Ò²ÓÐÀýÍâµÄÇé¿ö£¬±ÈÈçͬÑùÊÇTomcat7£¬ÔÚÕâ¸ö´ó°æ±¾ÖеÄijЩС°æ±¾ÓпÉÄܲ»ÊÇĬÈÏÖ§³ÖServlet×¢½âµÄ£¬ÕâÀïÐèҪעÒâÁË¡£
×ܵÄÀ´Ëµ£¬²»¹ÜTomcatÊÇ·ñĬÈÏÖ§³ÖServlet×¢½â£¬×îºÃÊÇ°ÑÕâ¸öÊôÐÔµÄÖµÉèÖÃΪfalse£¬·ÀÖ¹ÄãµÄÏîÄ¿Copyµ½ÆäËûϵͳÖÐÔËÐеÄʱºò³öÏÖÎÊÌ⣬Õâ¾ÍÊÇÄãµÄÎÊÌâÁË¡£