Struts2.3.15搭建項目執行個體

來源:互聯網
上載者:User

1 隨著struts2的改版,現在改的越來越亂了,用了很多自己的東西,要匯入的包越來越多了,截下圖吧,感覺越來越不好用了,這9個缺一不可


2 主配置

<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">  <filter><filter-name>struts2</filter-name><!-- <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>--><!-- --><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>  </filter><!-- FilterDispatcher用來初始化struts2並且處理所有的WEB請求。 --><filter-mapping><filter-name>struts2</filter-name> <url-pattern>/*</url-pattern><!-- <url-pattern>*.action</url-pattern>  --></filter-mapping>      <display-name>ss2</display-name>  <welcome-file-list>    <welcome-file>index.html</welcome-file>    <welcome-file>index.htm</welcome-file>    <welcome-file>index.jsp</welcome-file>    <welcome-file>default.html</welcome-file>    <welcome-file>default.htm</welcome-file>    <welcome-file>default.jsp</welcome-file>  </welcome-file-list></web-app>

這裡面有 原先的配置和後來的,新的jia肯定不再適合原來的主類了

3 src下建立struts.xml

<!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN""http://struts.apache.org/dtds/struts-2.0.dtd"><struts><package name="main" extends="struts-default" ><action name="mainAction" class="com.YCHZ.jquery.action.LoginAction"method="execute"><result name="success">/success.jsp</result><result name="error">/error.jsp</result></action></package></struts>

4 建立action

package com.YCHZ.jquery.action;import com.opensymphony.xwork2.ActionSupport;public class LoginAction extends ActionSupport{public String execute(){System.out.println("ok");return SUCCESS;}}


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.