我想成为""从Request变量获取参数后,而不是null。
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;
}
在行String around(ServletRequest req, String s): getParam(req, s) {
Eclipse中显示此消息:在aspects.GetParameterOrAttribute中定义的建议尚未应用
[Xlint:adviceDidNotMatch]
答案 0 :(得分:1)
将执行更改为调用,将ServletRequest更改为ServletRequest +。应捕获对ServletRequest及其子类的所有getParameter调用。