这是我的ControllerClass
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
我制作了模型,并在那里添加了吸气剂和吸气剂。
我做错了什么?无法弄清楚。
最佳答案
根据您的代码,属性的名称为'ScheduleClass'而不是'wiziqClass'...因此,请更改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}