0

这是我的控制器类

public class ScheduleClassController extends SimpleFormController {

public ScheduleClassController() {
    setCommandClass(ScheduleClass.class);
    setCommandName("scheduleClass");
}

protected ModelAndView onSubmit(HttpServletRequest request,
        HttpServletResponse response, Object command) throws Exception {

    ScheduleClass wiziqClass = (ScheduleClass) command;
    System.out.println(wiziqClass);
    return new ModelAndView("classdetail", "ScheduleClass", wiziqClass);

}
}

这是我的 springapp-servelet.xml

http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="viewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass"
        value="org.springframework.web.servlet.view.JstlView" />
    <!-- <property name="prefix" value="/WEB-INF/jsp/" /> -->
    <property name="suffix" value=".jsp" />
    <property name="order" value="10" />
</bean>

<bean name="/index.htm" class="org.sakaiproject.wiziq.tool.HelloWorldController">
    <property name="sakaiProxy" ref="org.sakaiproject.wiziq.logic.SakaiProxy" />
</bean>

<bean name="/schedule.htm" class="org.sakaiproject.wiziq.tool.ScheduleClassController">
    <property name="formView" value="schedule" />
    <property name="successView" value="classdetail" />
</bean>

这是我的 classdetail.jsp

<jsp:directive.include file="/templates/includes.jsp" />
<jsp:directive.include file="/templates/header.jsp" />

hello there
${wiziqClass.name}

<jsp:directive.include file="/templates/footer.jsp" />

提交表单后,我登陆了这个视图,但没有在这里获取 wiziqClass.name 我已经制作了 Model 并在那里添加了 getter 和 setter。

我做错了什么?想不通。

4

3 回答 3

1

Please change any one of place . Don't change in two places.

 protected ModelAndView onSubmit(HttpServletRequest request,
      HttpServletResponse response, Object command) throws Exception {

      ScheduleClass wiziqClass = (ScheduleClass) command;
      System.out.println(wiziqClass);
      return new ModelAndView("classdetail", "wiziqClass", wiziqClass);
}

or

 ${ScheduleClass.name}
于 2013-08-22T10:46:42.193 回答
0

According to your code the name of the attribute is 'ScheduleClass' and not 'wiziqClass'... So change the expression in your jsp

protected ModelAndView onSubmit(HttpServletRequest request,
    HttpServletResponse response, Object command) throws Exception {

  ScheduleClass wiziqClass = (ScheduleClass) command;
  System.out.println(wiziqClass);
  return new ModelAndView("classdetail", "ScheduleClass", wiziqClass);
}

${ScheduleClass.name}

于 2013-08-22T10:48:14.333 回答
0

得到它的工作主要问题是onSubmit没有工作我错误地从中删除了BindException错误
onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,BindException errors) ,这导致了错误第二个错误是M.Dienum告诉的

感谢你们俩

于 2013-08-22T11:07:18.010 回答