Struts2 Restful Mapping配置

时间:2013-07-05 08:14:35

标签: struts2 action mapper

我是struts2的新手,我尝试使用Restful,但我无法配置。

我有2个控制器:

UsersController

@Namespace("/api")
public class UsersController extends ActionSupport implements ModelDriven<Object> {
}

ListController

@Namespace("/api/users/{user_id}")
public class ListController extends ActionSupport implements ModelDriven<Object> {
}

我想像这样创建API:

  

/ api / users / - &gt;方法UsersController.index

     

/ api / users / {user_id} - &gt;方法UsersController.show

     

/ api / users / {users_id} / list - &gt;方法ListController.index

     

/ api / users / {users_id} / list / {list_id} - &gt;方法ListController.show

我尝试了配置 struts.properties

struts.devMode = true
struts.convention.action.suffix = Controller
struts.convention.action.mapAllMatches = true
struts.convention.default.parent.package = rest-default
struts.convention.package.locators = controller
struts.rest.defaultExtension = json
struts.action.extension = 
struts.mapper.alwaysSelectFullNamespace = false
struts.mapper.idParameterName = id
struts.patternMatcher = namedVariable
struts.mapper.class = org.apache.struts2.dispatcher.mapper.Restful2ActionMapper
struts.enable.SlashesInActionNames = true

它不像我想要的那样工作。

你有什么建议吗?

0 个答案:

没有答案