我写了一个简单的代码来将rest与Struts 2.3.24集成
我有我的 Struts XML:
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.mapper.class" value="rest" />
<!-- Overwrite Convention -->
<constant name="struts.convention.action.suffix" value="Controller"/>
<constant name="struts.convention.action.mapAllMatches" value="true"/>
<constant name="struts.convention.default.parent.package" value="com.pag.rest.service"/>
<constant name="struts.convention.package.locators" value="service"/>
</struts>
Run Code Online (Sandbox Code Playgroud)
我的控制器类是:
package com.pag.rest.service;
public class RequestController {
// GET
public String index() {
return "SUCCESS";
}
// GET
public String show() {
return "SUCCESS";
}
// POST
public String create() {
return "Create - SUCCESS";
}
// PUT
public String update() {
return …Run Code Online (Sandbox Code Playgroud)