Struts2学习

struts2学习: web.xml配置filter: <filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping> struts.xml配置action: <struts><constant name="struts.devmode" value="true"></constant> //开发模式,自动配置修改 <package name="default" namespace="/" extends="struts-default"><action name="hello"><result> /hello.jsp </result></action></package></struts> struts2运行机制: 客户端发送请求到服务器,服务器根据url判定所访问的application,接着查看该application下的配置文件web.xml,在配置文件中配置的filter会过滤掉所有的url地址,然后交给StrutsPrepareAndExecuteFilter这个类进行处理,这个类会调用dofilter()方法从struts2的配置文件中调用相应的namespace()以及action,返回相应的result,最后将result反馈给客户端。

猜你喜欢

转载自asurada.iteye.com/blog/2355160