[英]Configure Spring REST Controller without DispatcherServlet
I want to setup Rest Controller using Spring without DispatcherServlet. 我想使用没有DispatcherServlet的Spring设置Rest Controller。
I have worked with Rest Controller with Spring MVC's dispatcher servlet but I am not sure how to setup controllers without it. 我曾与Spring MVC的调度程序servlet一起使用Rest Controller,但我不知道如何在没有它的情况下设置控制器。
Below is the code that I tried: 以下是我尝试过的代码:
@Controller
@RequestMapping("/somemapping")
public class SomeControllerImpl implements SomeController {
@Autowired
private SomeService service;
@Override
@ResponseBody
@RequestMapping(value = "/", method = RequestMethod.GET)
public List<DO> getAllDO() {
return service.getAllDO();
}
}
When I tried accessing above controller using "localhost:8080/appName/somemapping/" it gave 404 error. 当我尝试使用“localhost:8080 / appName / somemapping /”访问上述控制器时,它给出了404错误。
Edit: I have Websphere application server. 编辑:我有Websphere应用服务器。 If that has something to do with my issue.
如果这与我的问题有关。
You can access the above controller's GET method using http://localhost:8080/somemapping/ 您可以使用http:// localhost:8080 / somemapping /访问上述控制器的GET方法
Instead of giving @RequestMapping(value = "/")
, you can also give value as value=""
您也可以将值赋予
value=""
而不是给出@RequestMapping(value = "/")
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.