开发者

Spring config string format

开发者 https://www.devze.com 2023-01-22 02:56 出处:网络
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.

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

精彩评论

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