Skip to content

Five minutes quick start

itstamen edited this page Mar 2, 2012 · 39 revisions

case descripton

We need to create new account through Rop framework.

Step

Step 1:create the rop request of create new user:

    package com.stamen.sample.rop.request;

import com.stamen.rop.RopRequest;
import org.springframework.format.annotation.NumberFormat;
import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Pattern;

public class CreateUserRequest extends RopRequest {

@Pattern(regexp = "\\w{4,30}")//① constraint of the field
private String userName;

@Pattern(regexp = "\\w{6,30}")//②
private String password;
 
@DecimalMin("1000.00")
@DecimalMax("100000.00")
@NumberFormat(pattern = "#,###.##")//③
private long salary;

//getter and setter...
}

The ①、② and ③ is the JSR 303 annotation,ROP use the JSR 303 to validate the request data.If the request datais invalid ,ROP will generate the standard error respone(see the ROP error system for detail).

Step 2:create rop response of create new user

Clone this wiki locally