Home > Java > javaTutorial > body text

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

怪我咯
Release: 2017-06-30 10:46:46
Original
1524 people have browsed it

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="//m.sbmmt.com/java/java-ActiveRecord-Model.html" target="_blank"></a>


####################################### ###@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";
 }
Copy after login
######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;
 }
}
Copy after login
###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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template