---
title: "struts2 标签 if 判断一个字符"
author: "hacker507"
date: "2012-12-01T18:09:29Z"
tags: []
categories: ["开源软件"]
slug: "struts2-if"
draft: false
lastmod: "2012-12-01T18:16:28Z"
id: 1739496
url: "https://hacker507.iteye.com/blog/1739496"
---

注意写法
Why won't the 'if' tag evaluate a one cha 

If care is not taken with the quoting of literals, the expression language (OGNL) will misinterpret a char as a String.
错误写法
if test="aStringProperty == 'A'"> Why doesn't this work when myString is equal to A? if>
The solution is simple: flip the double and single quotes.

正确写法
if test='aStringProperty == "A"'> This works! if>
Another solution is to escape the double quotes in the String.

正确写法
if test="aStringProperty == \"A\""> This works too! if>