使用Spring 2.5 MVC,每个请求都会调用两次Controller。这是配置问题。
点击按钮,javascript功能会做一些过程&提交带有帖子请求的表单
由于我只通过javascript一次提交表单,因此无理由调用控制器的生成方法两次。
Spring Tiles配置:
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<util:list>
<value>/WEB-INF/classes/tiles/va_tiles.xml</value>
</util:list>
</property>
<bean id="resourceViewResolver"
class="org.springframework.web.servlet.view.ResourceBundleViewResolver"
p:order="0" p:basename="spring.my_views" />
<bean id="urlViewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver"
p:order="1" p:viewClass="org.springframework.web.servlet.view.JstlView" />
</bean>
JSP:
<form:form id="sampleForm" command="sampleCommand">
........
........
<input type="button" onclick="javascript: return somefunction(form, actionUrl, method)"/>
........
........
<form:form>
控制器:
@Controller
@RolesAllowed(value = { ....})
@SessionAttributes( { ERROR_RESPONSE, SUCCESS_MESSAGE, WARNING_MESSAGE })
public class MyController extends BaseController {
----
@RequestMapping(value = "/sample.htm", method = RequestMethod.POST)
public ModelAndView generate() {
........
........
}
----
}
提前致谢。
Srihari
答案 0 :(得分:1)