我正在使用stripesframework开发一个web应用程序,但遇到了一个问题。我在附近找到了工作,但我想知道为什么会发生这种情况。
我写了一个类,像这样
@UrlBinding("/subject/{subject_type}/{subject_name}")
public class SubjectActionBean extends ActionBean {
private String subjectType;
private String subjectName;
@Validate(required = true)
public void setSubjectName(String subjectName) {
this.subjectName = subjectName;
}
@Validate(required = true)
public void setSubjectType(String subjectType) {
this.subjectType = subjectType;
}
@DefaultHandler
public Resolution view() {
return new Resolution();
}
}其中,subject_type和subject_name会根据从中调用操作的主题页面而变化。因此,调用应该是localhost/subject/applied/math。
在此之前,它工作得很好。当我尝试创建一个remove方法时出现了这个问题
@HandlesEvent("remove")
public void removeSubject() {
}并使用localhost/subject/applied/math/remove调用它,这时stripes开始抱怨调用没有处理程序,也没有默认处理程序。
因此,我删除了路径中的"{subject_type}/{subject_name}“,并将它们作为参数传递,然后在方法中使用以下命令对它们进行解包:
getContext().getRequest().getParameter();这使得remove方法被调用。
我现在的问题是,为什么"{subject_type}/{subject_name}“使条带找不到remove方法。
发布于 2012-03-07 11:49:57
尝试将@UrlBinding更改为以下内容:
@UrlBinding("/subject/{subject_type}/{subject_name}/{$event}")如果没有URL,就无法判断{$event}参数的哪一部分应该是事件。
此外,为了进行测试,您可以尝试(使用当前@UrlBinding)访问localhost/subject/applied/math?remove=
希望这能有所帮助。
https://stackoverflow.com/questions/9595389
复制相似问题