4

我想从 SWF 流中的视图对 Spring MVC 控制器进行 AJAX 调用。我需要在 portlet 容器中执行此操作,而不是在 portlet 会话之外的 servlet。

我曾尝试在 Spring Controller 类中使用<portlet:resourceURL id="myAjax"/>和使用@ResourceMapping,但这会在 SWF FlowHandler 尝试处理请求时干扰它。

我想做的事可能吗?如果是这样,有人对如何做有任何建议吗?

谢谢。

4

1 回答 1

0

在我的 view-state1 春季网络流程中,我有这个:

<script type="text/javascript">
        function getInfoPersona(tipoSearch) {
            dojo.require("dojox.widget.Standby");

            if(tipoSearch == 'cedula'){
                var param = document.getElementById('cedula').value;
                if(!param){
                    return alert('Escriba una cédula');
                }
            }else{
                var param = document.getElementById('numero').value;
                if(!param){
                    return alert('Escriba un número');
                }               
            }
           var url = "/application/personae/info/"+tipoSearch+"/"+param+".json";            

           var standby = new dojox.widget.Standby({target: "loadingInfo"});
           document.body.appendChild(standby.domNode);
           standby.startup();           
            standby.show();
            dojo.xhrGet({
            // URL del recurso en el servidor
            url: url, 
            handleAs: "json",
            timeout: 5000, // Time in milliseconds

            // The LOAD function will be called on a successful response.
            load: function(response, ioArgs) { //
                if(response.nombre){
                    document.getElementById('infoPersona').innerHTML = '<ul>'+
                        //'<li>Estatus: '+response.estatus+'</li>'+         
                        '<li>Nombre: '+response.nombre+'</li>'+
                                '<li>Centro: '+response.centro+'</li></ul>';

                        if(tipoSearch == "cedula"){
                            if( response.numero > 0){
                                document.getElementById("numero").value = response.numero;
                                //document.getElementById("numero").readOnly = true;
                                document.getElementById("buttonSearchNumero").disabled = true;
                            }else{
                                //document.getElementById("numero").value = '';
                                document.getElementById("numero").readOnly = false;
                                document.getElementById("buttonSearchNumero").disabled = true;                              
                            }
                        }

                        if(tipoSearch == "numero"){
                            document.getElementById("cedula").value = response.cedula;
                            document.getElementById("cedula").readOnly = true;
                            document.getElementById("buttonSearchCedula").disabled = true;
                        }

                        if(response.ambito != ''){
                            document.getElementById('ambito').value = response.ambito;  
                        }


                        document.getElementById('twitter').value = response.twitter;

                        document.getElementById('correo').value = response.email;                           

                        document.getElementById('numeroTelefono').value = response.telefono;

                        if(response.parroquiaId > 0){
                            seleccionarMunicipioParroquia(response.parroquiaId, response.municipioId);                              
                        }


                        document.getElementById('infoPersona').style.visibility = 'visible';    
                        document.getElementById('success').disabled = false;
                }else{
                    if(tipoSearch == 'cedula'){
                        document.getElementById('infoPersona').innerHTML = 'No se encontraron datos';
                        document.getElementById('success').disabled = true;
                    }else{
                        document.getElementById('infoPersona').innerHTML = 'No se encontraron datos para el número de escrito';                     
                    }    
                    document.getElementById("buttonSearchCedula").disabled = false;
                    document.getElementById("buttonSearchNumero").disabled = false;
                }
                standby.hide();  
                document.getElementById('infoPersona').style.visibility = 'visible';    

            },

            // The ERROR function will be called in an error case.
            error: function(response, ioArgs) { // 
              console.error("HTTP STATUS CODE: ", ioArgs.xhr.status); //
              dojo.byId("infoPersona").innerHTML = 'No se pudo cargar la información básica de la persona'; //
              standby.hide();
              document.getElementById('infoPersona').style.visibility = 'visible';            
              return response; // 
              }
            }); 
          }
      </script> 

和我的控制器:

@RequestMapping(value = "/info/cedula/{cedula}.json", method = RequestMethod.GET, produces = "application/json")
    @ResponseBody
    public InfoPersona getPersonaAsJson(@PathVariable("cedula") Integer cedula) {

        InfoPersona te = new InfoPersona();
        Persona v = Persona.findPersonaByCedulaEquals(cedula);

        if(v == null){
            return te;
        }


        setDataPersona(v.getPersonaId(), te);

        te.setTipoBusqueda("cedula");

        if(!telefonosString.equals("")){
            //eliminar la coma final
            telefonosString = telefonosString.substring(0, telefonosString.length() - 1);
            te.setAllTelefonos(telefonosString);
        }

        te.setTelefonos(numeros);

        return te;
    }
于 2014-04-21T18:52:10.257 回答