Home >Java >javaTutorial >Detailed explanation of object parameter passing examples in spring MVC in JAVA
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
<a href="http://www.php.cn/java/java-ActiveRecord-Model.html" target="_blank"></a>
@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!