Home  >  Article  >  Java  >  Detailed explanation of object parameter passing examples in spring MVC in JAVA

Detailed explanation of object parameter passing examples in spring MVC in JAVA

怪我咯
怪我咯Original
2017-06-30 10:46:461393browse

This article mainly introduces you to the relevant information about passing object parameters in spring MVC. The article introduces it in detail through sample code, which has certain reference and learning value for everyone. Friends who need it Let’s take a look below.

Preface


####################################### ###@RequestParam###Annotation method is passed. I took a closer look recently and found that java also has a method similar to ###Asp.net### Mvc's way of passing objects as parameters, that is, using ###@###Model ###Attribute###Annotation method, ###reception method is as follows: ######
@RequestMapping("hello")
 public String Hello(@ModelAttribute("user") User user)
 {
   System.out.println(user.getUserName());
  return "hello";
 }
######User class is as follows: ######
public class User {

 private int userID;
 private String userName;
 public int getUserID() {
  return userID;
 }
 public void setUserID(int userID) {
  this.userID = userID;
 }
 public String getUserName() {
  return userName;
 }
 public void setUserName(String userName) {
  this.userName = userName;
 }
}
###Access method discovery and adoption There is no difference when passing parameters one by one. My local address is as follows: ###/test/hello?userID=12&userName=sdfsd###############

The above is the detailed content of Detailed explanation of object parameter passing examples in spring MVC in JAVA. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn