2012-12-20 15 views
0

我正在做一個簡單的表格,使用spring,稍後將連接一個ejb。我得到請求處理失敗,彈簧

所以我是JSP(我在我的JSP春季庫):

<form:form commandName="TestDTO" method="POST"> 
    <form:input path="test" maxlength="20" 
      id="test" /> 
    <input type="button" 
     onClick="javascript:validarCamposConsulta('consultaTest.htm')" 
     value="Consultar" class="boton" /> 
</form:form> 

我的控制器是這樣的(我從來就包聲明後春進口):

@Controller 
public class TestController { 
    protected final Log logger = LogFactory.getLog(getClass()); 
private final String testDTO = "TestDTO"; 

@RequestMapping("/consulta.htm") 
public ModelAndView preload(HttpServletRequest request, 
     HttpServletResponse response) throws ServletException, IOException { 
    String forward = "/consulta/CONSULTA"; 

    /*try { 
     configuradorIDA.setupIsbanDataAccess(); 
    } catch (Exception e) { 

     System.out.println("Error al inicializar IDA: " + e.getMessage()); 
    }*/ 
    return new ModelAndView(forward); 
} 

@RequestMapping("/consultaTest.htm") 
public final String consultaTest(
     @ModelAttribute(testDTO) 
     final TestDTO testdto, 
     final BindingResult result, 
     final ModelMap model, 
     final HttpServletRequest request, 
     final HttpServletResponse response) { 
    String forward = "/consulta/CONSULTA"; 
    testdto.getTest(); 
    model.addAttribute(testDTO, testdto); 
    return forward; 
} 

} 

I'm運行到WebSphere 7因此,當我運行它,我得到了一個錯誤:

Error 500: org.springframework.web.util.NestedServletException: 
Request processing failed; nested exception is 
java.lang.IllegalStateException: 
Neither BindingResult nor plain target object 
for bean name 'TestDTO' available as request attribute 

有誰知道事?

在此先感謝。

回答

0

OK看來我的方法預裝公司應

@RequestMapping("/consulta.htm") 
    public ModelAndView preload(@ModelAttribute(testDTO) 
    final TestDTO testdto, HttpServletRequest request, 
      HttpServletResponse response) throws ServletException, IOException { 

並解決它。