SpringMVC和带有Angular2的jdbc

时间:2017-07-25 07:35:12

标签: angular spring-mvc jdbc

更新鲜的SpringMVC和jdbc与Angular2,在我的控制器类中为UI控制器编写了一些方法,但Here Save方法在Postman应用程序中没有响应并且所有方法都正常工作。显示“414,404”BadRequest就像那个错误说plz给出任何人的保存方法

package com.employee.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.employee.bean.EmployeeDO;
import com.employee.service.EmployeeServices;

@RestController
@RequestMapping(value = "/employeeController")
public class EmployeeController {

    @Autowired
    private EmployeeServices employeeServices;

    @RequestMapping(value = "/SaveEmployee")
    @ResponseBody
    // CRUD " Create - Post, Read - Get, Update - Put, Delete - Delete
    public EmployeeVO saveEmployee(@RequestBody EmployeeVO employeeVO) {
         System.out.println("inside");
         EmployeeDO employeeDO = new EmployeeDO();
         employeeDO.setEmployeeId(employeeVO.getEmployeeId());
         employeeDO.setFirstName(employeeVO.getFirstName());
         employeeDO.setLastName(employeeVO.getLastName());
         employeeDO.setAddress(employeeVO.getAddress());
         employeeDO.setActiveIndicator(employeeVO.getActiveIndicator());
         employeeDO.setLastUpdatedUserId(employeeVO.getLastUpdatedUserId());
         employeeDO.setLastUpdatedTmstmp(employeeVO.getLastUpdatedTmstmp());
         employeeServices.saveEmployee(employeeDO);
        return employeeVO;
    }

    @RequestMapping(value = "/deleteEmployee", method = RequestMethod.POST)
    public void deleteEmployee(String employeeId) {
        System.out.println("delete");
        employeeServices.deleteEmployee(employeeId);
    }

    @RequestMapping(value = "/deleteEmployee2", method = RequestMethod.POST)
    public void deleteEmployeeRecord(String firstName) {
        System.out.println("dele2");
        employeeServices.deleteEmployeeRecordName(firstName);
    }

    @RequestMapping(value = "/findEmployees", method = RequestMethod.GET)
    // @ResponseBody
    public List<EmployeeVO> findEmployees() {
        System.out.println("sysos");
        List<EmployeeDO> employees = employeeServices.findEmployees();
        List<EmployeeVO> employeeVOList = new ArrayList<EmployeeVO>();
        for (EmployeeDO employee : employees) {
            EmployeeVO employeeVO = new EmployeeVO();
            employeeVO.setEmployeeId(employee.getEmployeeId());
            employeeVO.setFirstName(employee.getFirstName());
            employeeVO.setLastName(employee.getLastName());
            employeeVO.setAddress(employee.getAddress());
            employeeVO.setActiveIndicator(employee.getActiveIndicator());
            employeeVO.setLastUpdatedUserId(employee.getLastUpdatedUserId());
            employeeVO.setLastUpdatedTmstmp(employee.getLastUpdatedTmstmp());
            employeeVOList.add(employeeVO);
        }
        return employeeVOList;
    }

    @RequestMapping(value = "/loadEmployee", method = RequestMethod.POST)
    // @ResponseBody
    public EmployeeVO loadEmployee(String employeeId) {
        EmployeeDO employeeDo = employeeServices.loadEmployee(employeeId);
        EmployeeVO employeeVO = new EmployeeVO();
        employeeVO.setEmployeeId(employeeDo.getEmployeeId());
        employeeVO.setFirstName(employeeDo.getFirstName());
        employeeVO.setAddress(employeeDo.getAddress());
        employeeVO.setActiveIndicator(employeeDo.getActiveIndicator());
        employeeVO.setLastUpdatedUserId(employeeDo.getLastUpdatedUserId());
        employeeVO.setLastUpdatedTmstmp(employeeDo.getLastUpdatedTmstmp());
        return employeeVO;
    }
}

0 个答案:

没有答案