开发者

Spring config string format

A stupid question on formatting but not able to figure out the correct negate parameter. I've the following string value which needs to be passed开发者_Go百科 as a constructor arg through spring.

private final static String STRING_PATTERN = "\\<.*?>";

In spring config,

<bean class="com.test.TestBean">
<constructor-arg value="\\<.*?>" />
</bean>

As you can see, its not in the correct format. Can anyone please provide a clue ?

Thanks


Since Spring config is an XML file

  • there is no need to replace \ with \\ as in Java string literals
  • you need to replace < and > with &lt; and &gt;

So, you get

<constructor-arg value="\&lt;.*?&gt;" /> 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜