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 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分