From 0c2803b09b75b5aac26ad9d1e5061f77bf003d64 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 5 Apr 2017 14:50:48 +0300 Subject: juick-www: GetMapping and PostMapping --- juick-www/src/main/java/com/juick/www/controllers/Home.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'juick-www/src/main/java/com/juick/www/controllers/Home.java') diff --git a/juick-www/src/main/java/com/juick/www/controllers/Home.java b/juick-www/src/main/java/com/juick/www/controllers/Home.java index 4f597d5a..a362901c 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/Home.java +++ b/juick-www/src/main/java/com/juick/www/controllers/Home.java @@ -29,10 +29,7 @@ import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.*; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; @@ -59,7 +56,7 @@ public class Home { @Inject WebApp webApp; - @RequestMapping(value = "/{anything}/**", method = RequestMethod.GET) + @GetMapping("/{anything}/**") protected void parseAnyThing(HttpServletResponse response, @PathVariable String anything, @RequestParam(required = false, defaultValue = "0") int before) throws IOException { if (before == 0) { @@ -88,14 +85,12 @@ public class Home { com.juick.User user = userService.getUserByName(anything); if (user.getUid() > 0) { Utils.sendPermanentRedirect(response, "/" + user.getName() + "/?before=" + before); - return; } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); - return; } } - @RequestMapping(value = "/", method = RequestMethod.GET) + @GetMapping("/") protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { String tag = request.getParameter("tag"); if (tag != null) { -- cgit v1.2.3