无法跳转,400错误

无法跳转,400错误

老师看下代码哪里有错吗,点击提交报400错误,控制台输打印了一行

Field error in object 'persons' on field 'height': rejected value [160,55]; codes [typeMismatch.persons.height,typeMismatch.height,typeMismatch.double,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [persons.height,height]; arguments []; default message [height]]; default message [Failed to convert property value of type 'java.lang.String[]' to required type 'double' for property 'height'; nested exception is java.lang.NumberFormatException: For input string: "160,55"]]



package com.imooc.handler;

import com.imooc.entity.Persons;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * TODO {file desc}
 *
 * @version 1.0
 */
@Controller
public class BMIHandler {
    @RequestMapping("/cacultBMI")
    public ModelAndView cacultBMI(Persons person) {
        ModelAndView modelAndView = new ModelAndView();
        double bmi = person.getWeight() / ((person.getHeight() / 100) * (person.getHeight() / 100));
        System.out.println(bmi);
        if (bmi < 19) {
            modelAndView.addObject("msg", "多吃点,太瘦了!注意加强营养~");
            modelAndView.setViewName("bmi1");
        } else if (bmi >= 19 && bmi < 25) {
            modelAndView.addObject("msg", "该减肥了!注意加强锻炼~");
            modelAndView.setViewName("bmi1");
        } else if (bmi >= 25) {
            modelAndView.addObject("msg", "体重正常,注意保持~");
            modelAndView.setViewName("bmi1");
        }
        return modelAndView;
    }
}


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
好帮手慕阿满 2019-09-23 17:37:00

同学你好,400错误表示语义有误,当前请求无法被服务器理解。问一下同学jsp页面提交数据是什么样的呢?

祝:学习愉快~

提问者 z晓龙 2019-09-23 16:06:23
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
SSM主流框架入门与综合项目实战2018版
  • 参与学习           人
  • 提交作业       205    份
  • 解答问题       4317    个

Java中非常实用的SSM整合开发内容,从Spring开始,到MyBaits的进阶内容,再到SpringMVC的应用,最后是SSM整合开发案例,逐步深入,助你成长为一名Java工程师!

了解课程
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师