私がやりたいことは、プロジェクト内のすべての JSP ページを属性に関連付けることです。たとえば、次の 3 つのページがあるとします。
helloWorld.jsp
helloUniverse.jsp
ここでの属性は「操作」です。次のように適用できる方法はありますか?
helloWorld.jsp -> Operation: "HelloWorld"
helloUniverse.jsp -> Operation: "HelloUniverse"
から利用できるようにServletContextListener
:
public void contextInitialized(final ServletContextEvent event) {
final ServletContext ctx = event.getServletContext();
// Following is the code I wish for:
List<Class<Servlet>> pages = ctx.getAllPages();
for(Class<Servlet> page : pages) {
operationMap.put(page.getName(), page.getAttribute("operation"));
}
}
私はそれが非常にこじつけに見えることを知っています..しかし、このようなことは可能ですか?