hello guys i am try to use the StringUtils.remove Method but the below exception is raising i have include the jar file and StringUtils.lowercase and String.countsMatches is working only remove is not what may be the problem

<%@page import="org.apache.commons.lang.StringUtils"%>

this is how i imported and the exception is as follows

java.lang.NoSuchMethodError:
org.apache.commons.lang.StringUtils.remove(Ljava/lang/String;Ljava/lang/String;)
Ljava/lang/String;
有帮助吗?

解决方案

The remove(String,String) method was added to version 2.1 of commons-lang. It is not present in 2.0 and earlier.

Depending on which Servlet Container or Application Server you use (and which version of it), the server class path may contain an outdated version of commons-lang, which is used instead of your copy of commons-lang in the applications /lib folder. If that's your problem, you can configure your application to prefer the application class path, instead of the server class path.

其他提示

Because as far as I can see in javadoc StringUtils has method remove that accepts 2 string arguments and does not have one that accepts 3 arguments:

public static String remove(String str,
                            String remove)

see http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/StringUtils.html

Since there are different versions of StringUtils double check that your are working with the same version in development and deployment environment.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top