环境多文件配置<?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"> <display-name>TomcatEjb</display-name> <!-- Standard Action Servlet Configuration --> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml,/WEB-INF/struts-test.xml</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <!-- Standard Action Servlet Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <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>
MappingDispatchAction配置文件
org.apache.struts.actions
Class MappingDispatchAction
java.lang.Object
org.apache.struts.action.Action
org.apache.struts.actions.BaseAction
org.apache.struts.actions.DispatchAction
org.apache.struts.actions.MappingDispatchAction
public class MappingDispatchAction
An abstract Action that dispatches to a public method that is named by the parameter
attribute of the corresponding ActionMapping. This is useful for developers who prefer to combine many related actions into a single Action class.
To configure the use of this action in your struts-config.xml
file, create an entry like this:
<action path="/saveSubscription"
type="org.example.SubscriptionAction"
name="subscriptionForm"
scope="request"
input="/subscription.jsp"
parameter="method"/>
where 'method' is the name of a method in your subclass of MappingDispatchAction that has the same signature (other than method name) of the standard Action.execute method. For example, you might combine the methods for managing a subscription into a single MappingDispatchAction class using the following methods:
例子通配符的使用
<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd"> <struts-config> <action-mappings> <action path="/test/TestAction_*" type="com.test.action.TestAction" parameter="{1}TestAction"> <forward name="add" path="/test/addTest.jsp" /> </action> </action-mappings> </struts-config>
Action 对像
package com.test.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.actions.MappingDispatchAction; public class TestAction extends MappingDispatchAction { //additionTest public ActionForward addTestAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){ request.setAttribute("usb", "Struts 1.x Addition Successful..."); return mapping.findForward("add"); } //additionTest public ActionForward deleteTestAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){ request.setAttribute("usb", "Struts 1.x Delete Successful..."); return mapping.findForward("add"); } //additionTest public ActionForward listTestAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){ request.setAttribute("usb", "Struts 1.x List Successful..."); return mapping.findForward("add"); } }
相关推荐
主要介绍了struts2.5+框架使用通配符与动态方法常见问题 ,在文中给大家提到了Struts2.5框架使用通配符指定方法 ,需要的朋友可以参考下
这是一个很有用的Struts通配符文档,如果你还在迷惑中,下载吧!
10.为什么要使用struts2代替struts1.x 7 二、struts.xml配置及例程 7 1.配置文件的优先级 7 2.配置形式 8 3.package配置相关 8 4.分工合作include:指定多个配置文件 10 5.tomcat认证访问 10 6.初识拦截器 11 7....
Struts2_Action学习笔记、通配符{1},{2}......
所有通配符以及用法.pdf所有通配符以及用法.pdf所有通配符以及用法.pdf所有通配符以及用法.pdf所有通配符以及用法.pdf所有通配符以及用法.pdf
struts2动态调用之通配符,相当于是改进的method动态调用方法,减少对同一action不同method的多次配置
还支持通配符搜索,使用星号(*)和问号(?)等字符进行模糊匹配。可设置排除过滤器,从搜索结果中排除特定类型的文件或文件夹,缩小搜索范围。除图形界面外,还提供命令行界面,满足高级用户的灵活需求。 特点:...
27.13.1 示例程序1 342 27.13.2 示例程序2 343 27.14 小结 345 附录A Struts配置 346 附录B JSP EL语言 361 附录C Java注解 370 序言 Servlet①技术和1JSP(JaLvaServer Pages)是利用Java语言开发Web/_立用程序...
struts2通配符的使用详解
1、struts2概述 Struts2 软件下载 Struts2 比较重要的类 操作步骤及框架配置 struts运行机制 2、简单的struts2程序 3、struts2配置文件 4、cion主要内容 Namespace、自定义Action、路径问题、通配符、包含模块...
通过示例代码演示Struts2配置中通配符的用法,代码很简单,只为说明
NULL 博文链接:https://angelnight.iteye.com/blog/549617
在struts2项目开发中,使用通配符优化配置文件,可以位项目开发节约大量的时间!
win-acme是一款免费SSL证书自动获取和部署工具,由于官方下载慢,特提供Csdn版本供使用. 具体的使用教程可看我收集的好文地址https://blog.csdn.net/r657225738/article/details/103778925
文件通配符匹配代码,与windows文件搜索匹配一样功能
使用node.js v8.x - v12.x测试。 落日 从Socket.io v2.0.4( )开始,您可以使用套接字中间件来捕获每个传入的Packet,这可以满足大多数socketio-wildcard的用例。 io . on ( 'connection' , ( socket ) => { ...
WPS 通配符使用全局替换,WPS 中文匹配,WPS正则使用
最快文件搜索利器Everything时隔半年迎来v1.4.1正式版,修复了诸多...它小巧免费,界面简洁,实时跟踪更新,轻松分享文件索引,支持通配符、正则表达式,可以通过HTTP或FTP分享搜索结果。Everything只适用NTFS文件系统