eclipse中tomcat啟動正常,但是無法顯示首頁

來源:互聯網
上載者:User

今天嘗試搭建了struts2環境,並且編寫了第一個struts程式–HelloWorld。環境搭建很順利,主要分為3步:引入jar包,編寫struts.xml,配置web.xml。詳情可以參考:http://www.blogjava.net/lzhidj/archive/2008/07/08/213445.html

但是有一個問題困擾:tomcat可以啟動成功,但是就是“此程式無法顯示網頁”。查閱後的解決辦法:
http://www.mamicode.com/info-detail-492134.html。
主要是因為tomcat配置的server path不是tomcat的安裝路徑,而且要選擇使用tomcat installation。部署直接選取webapps。
這個問題真是困擾了幾個小時,特依此警戒。

另外,還有web.xml中

<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">  <display-name>Struts</display-name>  <welcome-file-list>    <welcome-file>index.jsp</welcome-file>  </welcome-file-list>  <context-param>    <param-name>contextConfigLocation</param-name>    <param-value>classpath:ApplicationContext*.xml</param-value>  </context-param>  <listener>    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  </listener>  <filter>    <filter-name>struts2</filter-name>    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>  </filter>  <filter-mapping>    <filter-name>struts2</filter-name>    <url-pattern>/*</url-pattern>  </filter-mapping></web-app>

listener 和 fliter 都要寫。老師在示範時,也沒有寫,但是就沒有問題,疑問。。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.