---
title: "学习struts2遇到的一些问题"
author: "mlkimg"
date: "2010-06-09T13:30:00Z"
tags: []
categories: ["企业架构"]
slug: "struts2"
draft: false
lastmod: "2010-07-17T20:48:55Z"
id: 687928
url: "https://mlkimg.iteye.com/blog/687928"
---

一下是鄙人学习struts2的总结

 

1.当用到redirectAction转发到另一个action时，struts2内部会new一个action（这也是struts1和struts2的区别之一），所以如果原来的状态请求会丢失，使用action链则不会出现这丢失状态请求的问题（chain）

 

2.struts2.1.6之前的版本在web.xml中的过滤器是org.apache.Struts2.dispatcher.FilterDispatcher，之后的是org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

 

3.struts2 中s:if 判断标签注意:

&lt;s:if test='ISLOCK=="Y"'&gt;是&lt;/s:if&gt; 

&lt;s:if test='ISLOCK=="N"'&gt;否&lt;/s:if&gt;

不管是数字，CHAR，VARCHAR2都能正确判断，不要写成

&lt;s:if test="ISLOCK=='N'"&gt;否&lt;/s:if&gt;

注意单引号和双引号位置。

双引号在外的时候，如果数据类型是超过一个字符的类型，判断正常。

但是如果是一个字符，则无法判断，用 &lt;s:if test="ISLOCK==\\"N\\""&gt;否&lt;/s:if&gt;这样也能判断出来，但是无法和多个字符统一，所以推荐写法是单引号在外。