鍏堟潵鎶婅繖涓獁eb app琛ュ厖涓涓嬪惂錛屽氨鏄竴涓猦ello world
棣栧厛淇敼 src/main/webapp/WEB-INF鐩綍涓嬬殑 web.xml錛?br />
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>my Web Application</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/my-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>my</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>my</servlet-name>
<url-pattern>/my/*</url-pattern>
</servlet-mapping>
</web-app>
榪欓噷錛寃eb-app鐨勭増鏈槸2.5錛屾棭鏈熺殑鐗堟湰鏄笉鏀寔EL鐨勶紝鐗堟湰鍙蜂笉瀵癸紝浠ュ悗浼氭湁闂
闄や簡servlet涔嬪錛寃eb.xml閲岃繕鏈変竴浜涘弬鏁幫細
contextConfigLocation瀹氫箟浜唖pring web鐨勯厤緗枃浠訛紝鑰宭istener鍒欒〃紺虹敱spring鐨凜ontextLoaderListener鏉ュ姞杞借繖涓厤緗枃浠?br />
my-servlet.xml鍒欏涓嬩緥錛?br />
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<mvc:view-controller path="/" view-name="index"/>
</beans>
榪欓噷瀹氫箟浜嗕竴涓猻pring鐨剉iew resolver錛岃繖涓獀iew resolver灝辨槸鎸夌収MVC鐨勬鏋訛紝鏉ユ壘鍒板搴旂殑view鐨勩侷nternalResourceViewResolver灝嗕細鏍規嵁URL鏉ュ喅瀹氭樉紺哄摢涓猨sp銆傝繖浜沯sp鏂囦歡閮藉湪 WEB-INF鐩綍涓嬨?br />
<mvc:view-controller path="/" view-name="index"/>
鍒欐槸鐩存帴鎶婃牴鎸囧悜浜唅ndex錛岄氳繃view resolver錛屽畠鍏跺疄鏄寚鍚戜簡 WEB-INF/index.jsp
maven 鍦ㄥ緩欏圭洰鐨勬椂鍊欙紝鍦╯rc/main/webapp涓嬭嚜鍔ㄧ敓鎴愪簡涓涓猧ndex.jsp錛屽彲浠ユ妸瀹冪Щ鍒?WEB-INF鐩綍涓?br />
涓嬩竴姝ワ紝鍐嶆墦寮 pom.xml錛屾妸榪欐鍔犺繘鍘伙細
<build>
<finalName>my</finalName>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.26</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
榪欓噷瀹氫箟浜嗕袱涓猵lug-in錛屼竴涓緢鏄庢樉錛屾剰鎬濇槸鐢╦ava 1.6鐗堟湰鏉ュ仛緙栬瘧銆傝屽彟涓涓垯鏄痬aven鐨刯etty鎻掍歡錛宩etty鏄竴涓獁eb server銆?br />
濂戒簡錛屽啀build涓嬈?br />
mvn clean install
鐒跺悗榪愯鍛戒護
mvn jetty:run
灝辨槸鍚姩涓涓猨etty錛屽茍涓旀妸鏈」鐩甦eploy銆傚惎鍔ㄥ畬鎴愬悗錛屽氨鍙互鐢ㄦ祻瑙堝櫒鎵撳紑
http://localhost:8080/my-webapp/my/

]]>