解决Java的SSM框架前端传输到controller层String类型数据为null的问题

解决Java的SSM框架前端传输到controller层String类型数据为null的问题

前端:

  

controller层:

package com.ssm.controller;

import com.ssm.model.User;
import com.ssm.service.UserService;
import org.omg.CORBA.Request;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import sun.net.idn.Punycode;

@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    @RequestMapping("/getLogin")
    public String getLogin(String username1, String password1) {
        User user = new User(username1, password1, 1);
        if (userService.doRegister(user)) {
            return "redirect:/login_register.jsp";
        } else {
            return "redirect:/login_register.jsp";
        }
    }


}

注意前端input标签中的name属性值要与controller层与之对应的方法体中的参数值保持一致。

你可能感兴趣的:(IT,IDEA,Java,SSM框架,前后端交互问题解决,SSM框架,前后端交互,问题解决)