質問

Am a newbie to Java & Restlet.

Am writing a function to get the post params and calls another function internally.

My doubt is if my code is something like this:

Form form = new Form(entity);
String abc = form.getFirstValue("abc");

And if the param abc is not passed, what would be the exception or what would be stored in abc?

役に立ちましたか?

解決

I found this source code: Series. Your Form class extends this Series class.

If parameter 'abc' not exists, then null (defaultValue) will be returned:

public String getFirstValue(String name) {
    return getFirstValue(name, false);
}

public String getFirstValue(String name, boolean ignoreCase) {
    return getFirstValue(name, ignoreCase, null);
}

public String getFirstValue(String name, boolean ignoreCase, String defaultValue) {
    String result = defaultValue;
    NamedValue<String> param = getFirst(name, ignoreCase);

    if ((param != null) && (param.getValue() != null)) {
        result = param.getValue();
    }

    return result;
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top