在Spring MVC Controller和模型之间传递对象

时间:2014-06-13 21:26:46

标签: spring

我是Spring MVC的新手。我创建了一个这样的控制器,模型是POJO。当我构建我的应用程序时,它给了我错误:

控制器:

import java.io.IOException;




import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;


import com.model.dto.BillingContactDto;


/**
 * The Class BillingController.
 */
@Controller
public class BillingController extends BillingBaseFormController {

    /** The log. */
    private static final Logger LOG = LoggerFactory.getLogger(BillingController.class);


    //model class
    private BillingContactDto billingContactDto;
       //this is how I believe I should link both of them
       @ModelAttribute("emp")
        public BillingContactDto getEmployee(@RequestParam("empdId") Long id) {
            // Get employee using empId from DB
            return  billingContactDto;
        }

        @RequestMapping(value = "/showEmpDetail", method = RequestMethod.GET)
        public String showEmpDetails()  {
            return "showEmpDetail";
        }

错误

[ERROR] C:\src\billing\web\src\main\java\com\billing\webapp\controller\company\BillingController.java:[142,12] error: cannot find symbol.

我需要一些关于我哪里出错的指导。 提前致谢

0 个答案:

没有答案