0

I have called struts action through json like this

function(){ 
    var data = {};
    data['userLogin.userName'] = $('#username').val().trim();
    data['userLogin.password']  = $('#password').val().trim();


    $.ajax({url:'loginAction', 
        cache: false,
        data:data, 
        dataType: 'json'
        });     
};  

.

this is my struct action mapping code segment

<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">



    <struts>

    <constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory"/>

    <!-- Configuration for the default package. -->
    <package name="default" extends="struts-default,json-default">



      <action name="loginAction" class="loginAction" method="doLogin">
            <result name="success">/test.jsp</result>
            <result name="error">/index.jsp</result>
      </action>
    </package>



</struts>

and this is my spring configuration file data

<bean id="loginDAO" class="com.mls.dao.LoginDAOImpl"></bean>

<bean id="loginService" class="com.mls.service.LoginServiceImpl">
    <property name="loginDAO" ref="loginDAO"></property>
</bean> 

<bean id="loginAction" class="com.mls.action.LoginAction">
    <property name="loginService" ref="loginService"></property>
</bean> 

loginSerice return success but navigation is not working. Give me idea how to fix this?

4

1 回答 1

1

这是ajax请求。如果您想重定向到其他网址,您必须在 javascript 中执行此操作。阅读http://www.w3schools.com/ajax/default.asphttp://api.jquery.com/jQuery.ajax/

于 2012-10-30T10:38:36.457 回答