Spring MVC接收参数的方式

本文介绍了Spring MVC中三种接收参数的方法。第一种是通过User实体类接收,如`http://ip:port/项目名/user/test?username="se7en"&password="123"`;第二种是直接通过字符串参数接收,如`test2(String username,String password)`;第三种是使用`@RequestParam`注解接收,如`@RequestParam("username") String username`。注意实体类接收时参数名需对应get方法,`ModelAndView`的`setViewName`指定跳转页面,`addObject`添加对象到模型视图。" 41011163,1327608,手机游戏开发技术解析:cocos2d与Unity3D,"['游戏开发', 'Android', 'Unity3d', 'OpenGL', 'cocos2d']
摘要由CSDN通过智能技术生成

第一种接收参数的方式:

1、com.venustech.entity.User实体类属性:

Integer id  、String username、String password

2、controller控制层

package com.venustech.controller;


import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;


import com.venustech.entity.User;


@Contro

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值