---
title: "struts2 配置文件 struts.xml"
author: "wu423"
date: "2009-11-03T22:18:00Z"
tags: []
slug: "struts2-struts-xml"
draft: false
lastmod: "2009-11-03T22:21:33Z"
id: 509588
url: "https://wu423.iteye.com/blog/509588"
---

java代码：

 

```
<action name="*" class="com.ecc.struts2.web.action.ExampleSupport">   
            <result>/{1}.jsp</result>   
 </action> 
```

 

这种配置类似struts1.2中的ForwordAction  
如果我想直接访问一个jsp文件并且又想通过\*。do的方式访问。那么就可以如上这样配置  
例如我想访问a.jsp,可以这样写http://localhost:8080/app/a.do,struts2找不到a这个action就会映射到a.jsp。  
java代码：

```
<action name="login_*" method="{1}" class="com.ecc.struts2.web.action.LoginAction">   
            <result name="success">/view.jsp</result>   
            <result name="login">/login.jsp</result>   
 </action>  
```

 

 

这种配置方式类似于struts1.2中的DispatchAction name="login\_\*" ： 星号匹配方法名字 例如

会匹配到LoginAction的doXXX方法 这样你的action类可以不实现任何接口 具有更好的移植行。