Created
September 26, 2012 10:31
-
-
Save relax-more/3787243 to your computer and use it in GitHub Desktop.
lombok model & spring framework sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package my.snippet.model; | |
import lombok.Data; | |
import lombok.EqualsAndHashCode; | |
import org.hibernate.validator.constraints.NotEmpty; | |
@SuppressWarnings("serial") | |
@Data | |
public class Form { | |
@NotEmpty | |
private String table; | |
@NotEmpty | |
private String statsX; | |
@NotEmpty | |
private String statsY; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package my.snippet.controller; | |
import java.util.List; | |
import my.snippet.model.Form; | |
import my.snippet.service.MyService; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.stereotype.Controller; | |
import org.springframework.web.bind.annotation.ModelAttribute; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RequestParam; | |
import org.springframework.web.bind.annotation.ResponseBody; | |
@Controller | |
public class MyController extends AbstractController { | |
public static final Logger LOGGER = LoggerFactory.getLogger(StatsController.class); | |
@Autowired | |
private MyService service; | |
@RequestMapping(value = "/api/sample") | |
@ResponseBody | |
public List<?>sample(@ModelAttribute("Form") final Form form) throws ApiException { | |
try { | |
LOGGER.debug("form input:{}", form.toString()); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
throw new ApiException(ResultCode.INTERNAL_ERROR, e.getLocalizedMessage()); | |
} | |
return service.getAnyList(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment