提交 91bd3bc5 编写于 作者: 武汉红喜's avatar 武汉红喜

NewController

上级 f5a8eada
package com.whatsmars.spring.boot.controller;
import com.whatsmars.spring.boot.exception.BusinessException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -16,16 +17,37 @@ import java.util.Map;
@RequestMapping("/new")
public class NewController {
@RequestMapping("/t")
public Map<String, Object> t() {
@RequestMapping(value = "/t", method = RequestMethod.GET)
public Map<String, Object> query() {
Map<String, Object> m = new HashMap<String, Object>();
m.put("domain", "toutiao.im");
return m;
}
@RequestMapping("/e")
public String e(@RequestParam(required = false) String error) {
@RequestMapping(value = "/t", method = RequestMethod.POST)
public Map<String, Object> add() {
Map<String, Object> m = new HashMap<String, Object>();
m.put("domain", "toutiao.im");
return m;
}
@RequestMapping(value = "/t", method = RequestMethod.PUT)
public Map<String, Object> update() {
Map<String, Object> m = new HashMap<String, Object>();
m.put("domain", "toutiao.im");
return m;
}
@RequestMapping(value = "/t", method = RequestMethod.DELETE)
public Map<String, Object> delete() {
Map<String, Object> m = new HashMap<String, Object>();
m.put("domain", "toutiao.im");
return m;
}
@RequestMapping(value = "/e", method = RequestMethod.GET)
public HttpStatus e(@RequestParam(required = false) String error) {
if (error != null) throw BusinessException.build(error);
return "OK";
return HttpStatus.OK;
}
}
......@@ -49,7 +49,7 @@ public class SampleController {
return localeResolver;
}
@RequestMapping("/changeLang")
@RequestMapping(value = "/changeLang", method = RequestMethod.POST)
@ResponseBody
public String changeLang(HttpServletRequest request, HttpServletResponse response, @RequestParam String lang){
LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册