a727281751 2019-06-29 09:47 采纳率: 50%
浏览 371
已采纳

错误400速求支援,实在找不到原因

package com.hp.controller;

import com.hp.entity.Emp;
import com.hp.service.IEmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/empController")
public class EmpController {
@Autowired
private IEmpService empService;
@RequestMapping(value = {"/list"},method = {RequestMethod.POST})
public ModelAndView list() {
try {
System.out.println("员工列表");
Listemps = empService.selectEmps();
ModelAndView mv = new ModelAndView();
mv.addObject("emps",emps);
mv.setViewName("empManager/list");
return mv;
}
catch (Exception ex){
ex.printStackTrace();
return null;
}
}
@RequestMapping(value = {"/add"},method = {RequestMethod.GET})
public ModelAndView add(){
System.out.println("insert");
ModelAndView mv = new ModelAndView();
mv.setViewName("empManager/insert");
return mv;
}
@RequestMapping(value = {"/insert"},method = {RequestMethod.POST})
public ModelAndView insert(int deptno,Emp emp){
try {
boolean flag = empService.insertEmp(deptno,emp);
System.out.println("empno:"+emp.getEmpno()+"--"+"ename:"+"--"+emp.getEname()+"--"+"job"+emp.getJob()+"--"+"mgr"+emp.getMgr()+"--"+"sal"+emp.getSal()+"--"+"comm"+emp.getComm()+"--"+"hiredate"+emp.getHiredate()+"--"+"deptno"+deptno);
System.out.println("flag:"+flag);
return null;
}
catch (Exception ex){
ex.printStackTrace();
return null;
}
}
}


```<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <form action="/empController/insert" method="post">
        <table align="center" width="400px" cellpadding="10px" cellspacing="0px" border="1px">
            <tr>
                <td align="right" width="30%">员工编号</td>
                <td align="left" width="70%">
                    <input type="text" name="empno" size="20">
                </td>
            </tr>
            <tr>
                <td align="right" width="30%">员工姓名</td>
                <td align="left" width="70%">
                    <input type="text" name="ename" size="20">
                </td>
            </tr>
            <tr>
                <td align="right" width="30%">职位</td>
                <td align="left" width="70%">
                    <input type="text" name="job" size="20">
                </td>
            </tr>
            <tr>
                <td align="right" width="30%">上级领导</td>
                <td align="left" width="70%">
                    <input type="text" name="mgr" size="20">
                </td>
            </tr>
            <tr>
                <td align="right" width="30%">薪资</td>
                <td align="left" width="70%">
                    <input type="text" name="sal" size="20">
                </td>
            </tr>
            <tr>
                <td align="right" width="30%">佣金</td>
                <td align="left" width="70%">
                    <input type="text" name="comm" size="20">
                </td>
            </tr>
            <tr>
                <td align="right" width="30%">入职时间</td>
                <td align="left" width="70%">
                    <input type="text" name="hiredate" size="20">
                </td>
            </tr>
            <tr>
                <td align="right" width="30%">部门编号</td>
                <td align="left" width="70%">
                    <input type="text" name="deptno" size="20">
                </td>
            </tr>
            <tr>
                <td align="center" colspan="2">
                    <input type="submit" value="提交">
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
  • 写回答

1条回答 默认 最新

  • Eiffel_Wu 2019-06-29 10:49
    关注

    状态码报400,一般是类型转换错误,你的代码里有日期,可能需要转换下格式,在Emp实体类的日期上方加上注解@DateTimeFormat(iso = DateTimeFormat.ISO.DATE),建议在所有的实体类出现日期的上方都要加上注解,加上注解之后再试试,估计就可以解决你的问题了。另外,注意注解中时间的格式看你用的是Date,还是DateTime格式。你的JSP页面建议使用循环展示,你这样写代码不够灵活。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 运筹学中在线排序的时间在线排序的在线LPT算法
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧