0
我剛剛開始使用Ant。我想將一些數據附加到上下文值標記。java.util.regex.PatternSyntaxException:使用螞蟻在索引0附近發生非法重複
這裏是XML
的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/abc.xml</param-value>
</context-param>
</web-app>
,這裏是Ant構建目標
<target name="deploy">
<!-- edit web.xml to update context-param-->
<replaceregexp file="$web.xml" match='${web-app.context-param.param-value}' replace="${web-app.context-param.param-value},/WEB-INF/new.xml" />
</target>
,但這正顯示出
java.util.regex.PatternSyntaxException: Illegal repetition near index 0
${web-app.context-param.param-value}
^
at java.util.regex.Pattern.error(Pattern.java:1924)
at java.util.regex.Pattern.closure(Pattern.java:3104)
at java.util.regex.Pattern.sequence(Pattern.java:2101)
at java.util.regex.Pattern.expr(Pattern.java:1964)
at java.util.regex.Pattern.compile(Pattern.java:1665)
at java.util.regex.Pattern.<init>(Pattern.java:1337)
at java.util.regex.Pattern.compile(Pattern.java:1047)
at org.apache.tools.ant.util.regexp.Jdk14RegexpMatcher.getCompiledPattern(Jdk14RegexpMatcher.java:68)
at org.apache.tools.ant.util.regexp.Jdk14RegexpMatcher.matches(Jdk14RegexpMatcher.java:95)
at org.apache.tools.ant.taskdefs.optional.ReplaceRegExp.doReplace(ReplaceRegExp.java:336)
at org.apache.tools.ant.taskdefs.optional.ReplaceRegExp.replaceAndWrite(ReplaceRegExp.java:527)
at org.apache.tools.ant.taskdefs.optional.ReplaceRegExp.multilineReplace(ReplaceRegExp.java:522)
at org.apache.tools.ant.taskdefs.optional.ReplaceRegExp.doReplace(ReplaceRegExp.java:427)
at org.apache.tools.ant.taskdefs.optional.ReplaceRegExp.execute(ReplaceRegExp.java:487)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:854)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
我該如何做到這一點,以及出現什麼問題?