RESTful接口实现 Fulworx

码农软件 · 软件分类 · REST/RESTful项目 · 2019-03-11 16:44:24

软件介绍

Fulworx 通过一个简单的 Annotations 为 XWork 框架的 Action 增加了输出 RESTful 接口的功能,如下代码所示:

@URITemplate(uri="/someURI/user/{lastname}/{firstname}")
@Accessor("user")
public class UserAction implements CreateAction, ReadAction
{
    private User user;
    private String firstname;
    private String lastname;
    private UserService userService;

    public UserAction(UserService service){
        this.userService=service;
    }

    public String create()
    {
        user = this.userService.create(firstname,
                                       lastname,
                                       user.getEmail(),
                                       user.getPhone());
        if(user == null){
          //if user isn't found, insert firstname and lastname into
          //resource bundle message, and return a 404 status code
          throw new ApplicationException(
            new BundledErrorDetail("user.error.notfound",
                                   ResourceBundle.getBundle("ErrorMessages"),
                                   new Object[]{firstname, lastname}),
            404);
        }
        return SUCCESS;
    }

    public String read()
    {
        user = this.userService.read(firstname, lastname);
        return SUCCESS;
    }

    public User getUser()
    {
       return user;
    }

    public void setUser(User user)
    {
       this.user = user;
    }
    //also, getter / setter for firstname, lastname
}

本文地址:https://codercto.com/soft/d/1124.html

Algorithms

Algorithms

Sanjoy Dasgupta、Christos H. Papadimitriou、Umesh Vazirani / McGraw-Hill Education / 2006-10-16 / GBP 30.99

This text, extensively class-tested over a decade at UC Berkeley and UC San Diego, explains the fundamentals of algorithms in a story line that makes the material enjoyable and easy to digest. Emphasi......一起来看看 《Algorithms》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

URL 编码/解码
URL 编码/解码

URL 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具