请问 这两个配置的作用是什么啊?
见Struts2的说明:
struts.convention.package.locators
[b]Packages whose name end with one of these strings will be scanned for actions[/b]
即是,从这个字符串往后,才是Struts2 Convention Plugin扫描的开始。
默认的是action,actions,struts,struts2
struts.convention.package.locators.basePackage
扫描的基包,也即是,只有这个包的子包才被Struts2 Convention Plugin扫描
[b]参考官方文档的最后那个表格:[/b]
[url]http://struts.apache.org/2.1.8.1/docs/convention-plugin.html[/url]
Struts2 Convention Plugins使用以下方法来搜索类路径:首先,Convention会从根package中寻找包名含有struts,struts2,action或actions的任意packages。下一部,Convention从前一步找到的package以及其子package中寻找com.opensymphony.xwork2.Action的实现以及以 Action 结尾的类,下面为Convention寻找的类。接下来Convention需要确定 URL 的具体资源部分。第一步取消类名中的Action ,并以 ”-” 来分割类名的其他部分,且将每个分部的首字母转为小写。你也可以通过配置struts.convention.exclude.packages来告诉Convention忽略某些包,也可以设置struts.convention.package.locators用来更改Convention默认的根packages,最后你还可以设置struts.convention.action.packages,来让 Convention 只搜索特定 package 下的 Action。