struts2的入門程式

2021-07-10 21:22:32 字數 803 閱讀 1501

乙個struts2的入門程式:

一:匯入struts2的核心jar檔案

二:在web.xml檔案中配置struts2的**控制器(過濾器)

<?xml version="1.0" encoding="utf-8"?>

struts2

org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter

/*

三:編寫action類

有三種方式:

①乙個普通的類,既不實現任何介面,也不繼承任何類

②繼承actionsupport(最常用)

③實現action介面

package com.edu.action;

import com.opensymphony.xwork2.actionsupport;

public class testaction extends actionsupport

public string rega()throws exception

public string show()

}

四:在struts2的配置檔案中配置action

<?xml version="1.0" encoding="utf-8" ?>

/success.jsp

/error.jsp

頁面上表單的action的路徑為reg_methodname.action。

Struts2入門(一)Struts2簡介

本章簡要介紹一下struts2框架 1.概念 我們知道,springmvc框架是為了整合servlet設計的控制層框架,那麼還有其他的框架也實現了這個功能,那麼就是struts2。struts2是乙個基於mvc設計模式的web應用框架,它本質上相當於乙個servlet,在mvc設計模式中,strut...

struts2入門總結

第一 struts2框架下開發的步驟 匯入所需要的那幾個包 web.xml檔案中對filterdispatcher的配置 struts2.xml檔案中對action的配置 必須注意的問題 package中需要有namespace,訪問路徑是namespace actionname action類中不...

Struts2 入門概述

struts2 入門概述 struts2 主要是通過匯入struts2的jar包,通過struts2的struts.xml配置 和struts的 執行視 件,到客戶端。struts2部署 基本步驟 1 新建web project 單擊 finish 完成。2 匯入struts2 jar包 3 配置p...