开发者

Spring 2.5 MVC + controller is getting called twice for each request

Using Spring 2.5 MVC, Controller is getting called twice for each request. Is this a configuration issue.

onc开发者_如何学运维lick of the button, javascript function will do some process & submit the form with post request

generate method of the controller is getting called twice for no reason as i am submitting the form through javascript only once.

Spring Tiles Configuration:

<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:


@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() {
        ........
        ........
    }

----
}

Thanks in advance.

Srihari


Have you seen this question - perhaps a missing javascript link:

mvc-controller-is-being-called-twice

In the answer they user suggests that badly form resource link was calling the URL again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜