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リクエストです。他の URL にリダイレクトする場合は、JavaScript で行う必要があります。http://www.w3schools.com/ajax/default.asphttp://api.jquery.com/jQuery.ajax/を読んでください。

于 2012-10-30T10:38:36.457 に答える