小编Har*_*hal的帖子

使用 Struts 2 REST 插件的操作未映射错误

我写了一个简单的代码来将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)

java rest struts2 struts-action struts2-rest-plugin

5
推荐指数
1
解决办法
345
查看次数

标签 统计

java ×1

rest ×1

struts-action ×1

struts2 ×1

struts2-rest-plugin ×1