---
title: "Struts2标签字符串处理"
author: "mzl0517"
date: "2011-08-16T13:03:57Z"
tags: []
categories: ["开源软件"]
slug: "struts2"
draft: false
lastmod: "2011-08-16T13:03:57Z"
id: 1150353
url: "https://roteg.iteye.com/blog/1150353"
---

在struts2的标签中判断字符串时需要用引号引起来，如下有几个例子：

 

 

1、使用单选按钮，设置单选按钮的默认值

 

```
<s:radio value="U" list="{#{'U':'普通用户','S':'系统管理员'}"  name="usertype" />
```

 

   如上述所写，生成html后不会自动选中“普通用户”，需在 U 上加上引号，如下所示：

 

```
<s:radio value="＇U＇" list="{#{'U':'普通用户','S':'系统管理员'}"  name="usertype" />
```

 

２、使用 if 标签

 

```
<s:if test='%{#request.above==y}'>
   -----
</s:if>
```

   上述判断将不起作用，需在 y 上加上引号，如下所示：

 

```
<s:if test='%{#request.above=="y"}'>
   -----
</s:if>
```