bae 配置 struts2

来源:互联网 发布:劲舞团sf 9.2辅助源码 编辑:程序博客网 时间:2024/05/18 18:20

百度文档:

Struts2

Struts2是比较流行和成熟的mvc框架,目前经过验证的支持版本为2.3.1.2,请尽量选择该版本或更高版本。Java执行环境已支持struts2的主要功能,但以下功能点不支持或需要额外配置:

1、struts2 convention

不支持struts2的零配置,struts2的零配置是通过convetion插件来支持,在convetion插件中涉及到敏感操作。

2、ognl

struts2依赖于ognl,在使用ognl时需要配置一个listener,将ognl的安全管理器关闭。Listener的实现代码如下:

public void contextInitialized(ServletContextEvent sce) {OgnlRuntime.setSecurityManager(null);}

并在web.xml中将listener的配置加上。


根据文档需要在web.xml配置一下

<listener><listener-class>test.listener.ListenerOnBae</listener-class>    </listener>

import javax.servlet.ServletContextEvent;import javax.servlet.ServletContextListener;import ognl.OgnlRuntime;public class ListenerOnBae implements ServletContextListener{public void contextDestroyed(ServletContextEvent arg0) {}public void contextInitialized(ServletContextEvent sce) {OgnlRuntime.setSecurityManager(null);}}



原创粉丝点击