读书人

Spring3大URL路径解析器(附工程源代码

发布时间: 2012-11-03 10:57:43 作者: rapoo

Spring三大URL路径解析器(附工程源代码)

Spring有三个方法名称解析器(MethodNameResolver):


(1)ParameterMethodNameResolver

(2)InternalPathMethodNameResolver

(3)PropertiesMethodNameResolver

关于三个的使用方法,不必多说,网上可以搜到很多,这里只是简单的提下

ParameterMethodNameResolver在给定的路径后会有一个指定调用哪个方法的参数跟随

例如:http://localhost:9999/method/parameterMethodNameResolver?funcflg=getDate

getDate就是要调用的方法

InternalPathMethodNameResolver方法名包含在路径中

http://localhost:9999/method/internalPathMethodController/getDate

getDate就是要调用的方法

PropertiesMethodNameResolver 调用的方法写在=后面


http://localhost:9999/method/propertiesMethodController/suibian=getDate

getDate就是要调用的方法


相关的XML配置:

web.xml


Spring的配置文件:

mvc.xml

parameterMethod.xml


?

最后工程的访问路径为



ParameterMethodNameResolver ?http://localhost:9999/method/parameterMethodNameResolver?funcflg=getDate

InternalPathMethodNameResolver ?http://localhost:9999/method/internalPathMethodController/getDate

PropertiesMethodNameResolver ?http://localhost:9999/method/propertiesMethodController/suibian=getDate



工程源代码见附件





?

读书人网 >软件架构设计

热点推荐