0

I want to become "" instead of null after getting parameter from Request variable.

import javax.servlet.ServletRequest;

public aspect GetParameter {

    pointcut getParam(ServletRequest req, String s):
        target(req) && args(s) &&
        execution(String javax.servlet.ServletRequest.getParameter(String));

    String around(ServletRequest req, String s): getParam(req, s) { 
        String result = req.getParameter(s);
        if (result == null) {
            return "";
        }
        return result;    
}

in line String around(ServletRequest req, String s): getParam(req, s) { Eclipse show this mesage : advice defined in aspects.GetParameterOrAttribute has not been applied [Xlint:adviceDidNotMatch]

1 Answer 1

1

change execution to call, and ServletRequest to ServletRequest+. that should capture all the calls to getParameter on ServletRequest and its subclasses.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.