2012-12-20 16 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 { 

并解决它。