How to receive a page form list through spring MVC

Source: Internet
Author: User

I recently ran into a problem with spring mvc and searched the web for a lot of information. I can hardly see the solution!

For example: When we do bulk add or update, in the controller layer to receive the form data problem!

We do a batch of users to add the experiment!

User model:

public class User {
    
    //username
    private String username;
    Password
    private String password;
    
    Public String GetUserName () {return
        username;
    }
    
    public void Setusername (String username) {
        This.username = Username = = null? Null:username.trim ();
    }
    
    Public String GetPassword () {return
        password;
    }
    
    public void SetPassword (String password) {
        This.password = password = = null? Null:password.trim ();
    }
    
    Public User (string Username, string password) {
        super ();
        This.username = Username;
        This.password = password;
    }
    
    Public User () {
        super ();
    }
    
}

Control layer:

@Controller
@RequestMapping ("/") public
class Usercontroller {
    /**
     * Logger to this class * *
    private static final Logger Logger = Logger.getlogger (usercontroller.class);
        
    
    @RequestMapping ("/user") public
    void Test (list<user> users) {
        logger.debug Jsonarray.tojson (users);
    }
}

We are creating a JSP:

<%@ page language= "java" import= "java.util.*" pageencoding= "UTF

-8"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >

Now let's test it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.