HTTP 415错误-Unsupported media type详解
package com.cn.hnust.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.cn.hnust.domain.User;
import com.cn.hnust.service.IUserService;
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
private IUserService userService;
@RequestMapping("/showUser")
public String toIndex(HttpServletRequest request, Model model) {
// int userId = Integer.parseInt(request.getParameter("id"));
// User user = this.userService.getUserById(userId);
// model.addAttribute("user", user);
return "showUser";
}
@RequestMapping(value = "/GetUser", method = RequestMethod.POST)
public @ResponseBody
User GetUser(@RequestBody User user) {
user.setUserName("Wei");
return user;
}
}
相关文章
- C/C++通过HTTP实现文件上传与下载的示例详解
- 原生js XMLhttprequest请求onreadystatechange执行两次的解决
- 使用Tomcat无法访问http:localhost:8080的解决方法
- 百度站内搜索不支持https的解决方法(已测试)
- Tomcat启动成功但无法访问http://localhost:8080/的解决方法
- AndroidHttpClient详解及调用示例
- C#使用HttpClient对大文件进行断点上传和下载
- Docker下多容器搭建 lamp的详细过程(httpd+mysql+php+redis)
- 451错误是什么意思?HTTP网页错误代码403和451有什么区别?
- 使用Apache ab进行http性能测试