2013-02-04 79 views
1

我試圖訪問被分配這樣訪問彈簧模型對象

@RequestMapping(value = "{id}", method = RequestMethod.GET) 
public String getMethod(@PathVariable Long id, Model model) { 
    model.addAttribute("attrib", attribute); 
} 

我試圖訪問屬性對象在我的自定義標記庫這裏的Spring MVC的我的模型對象是碼。

@Override 
    public void doTag() throws JspException { 
     final JspWriter writer = getJspContext().getOut(); 
     try { 
      attribute = (Attribute) 
        getJspContext().getAttribute("attrib"); 
      if (attribute != null) { 
       System.out.print(attribute.getId()); 
      } 
      writer.println("sandeep"); 

     } catch (IOException e) { 
      e.printStackTrace(); 
     } 
    } 

但屬性總是來爲空,誰能告訴我如何從我的自定義標籤庫訪問屬性對象

回答