---
title: "UrlRewrite时需要注意的问题：action以及正则表达式"
author: "ocaicai"
date: "2011-12-15T13:57:48Z"
tags: ["Struts2", "action", "urlrewrite", "正则表达式"]
categories: ["Web前端"]
slug: "urlrewrite-action"
draft: false
lastmod: "2011-12-15T14:22:12Z"
id: 1312189
url: "https://ocaicai.iteye.com/blog/1312189"
---

\[color=green]myeclipse6.5+struts2-core-2.1.8.jar+urlrewrite-3.2.0.jar如果存在开发环境的问题，那么自己先建立一个项目，把相应的文件导入即可\[/color] \[color=red]1.注意：为了实现action访问的伪静态在web.xml中配置struts2和urlrewrite时，加上\[/color] \[code="xml"] REQUEST FORWARD \[/code] \[code="xml"] UrlRewriteFilter org.tuckey.web.filters.urlrewrite.UrlRewriteFilter confReloadCheckInterval 20 logLevel WARN UrlRewriteFilter /* REQUEST FORWARD struts2-execute org.apache.struts2.dispatcher.FilterDispatcher struts2-execute \*.action REQUEST FORWARD \[/code] \[color=red]2.注意：匹配字符串的时候或者每一个参数的时候都需要用小括号括起来 \[/color] \[code="xml"] ^/footer/(\[\\w\\s\*]+)$ /member/pages!toFooterPage.action?name=$1 member/pages!toFooterPage.action\\?name=(\[\\w\\s\*]+)$ /footer/$1 \[/code] \[color=green]就上面这个两个小问题，让我在使用UrlRewrite的时候折磨惨咯!带血的经验啊!\[/color] .