我得到请求处理失败的春天

时间:2012-12-20 19:36:03

标签: java spring-mvc

我正在使用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;
}

}

我在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

有谁知道发生了什么事?

提前致谢。

1 个答案:

答案 0 :(得分:0)

好吧,好像我的方法preload firm应该是

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

并解决了它。