getJson won't retrieve me anu result
Hi, im developing a jsp page using the struts technology. The problem is that i need to invoke a java class retrieving a JSON object from it, but at the moment it won't work
This is my jquery code
- $.getJSON( "checkData", {idp:idp},function( data ) {
- alert('json');
- //some code
-
- });
struts.xml is correctly configured to call the checkData.java class using the space name "checkData" that i pass in getJSON method.
The class is correctly invoked, because i see all details in the debugin console (i'm using netbeans).
The problem is that no result is retrieved by the jquery, in fact alert("json") is never called!
this is checkData.java
- package com.mycompany;
- import UnitOfWork.UnitOfWork;
- import Javabean.Provincia;
- import Javabean.Comune;
- import com.opensymphony.xwork2.ActionSupport;
- import java.sql.SQLException;
- import java.util.ArrayList;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- public class checkData extends ActionSupport{
-
- private ArrayList<Provincia> listaProvincie = new ArrayList<>();
- private ArrayList<Comune> listaComuni = new ArrayList<>();
-
- private int idp;
- public ArrayList<Provincia> getListaProvincie() {
- return listaProvincie;
- }
- public void setListaProvincie(ArrayList<Provincia> listaProvincie) {
- this.listaProvincie = listaProvincie;
- }
-
- public int getIdp() {
- return idp;
- }
- public void setIdp(int idp) {
- this.idp = idp;
- }
- public ArrayList<Comune> getListaComuni() {
- return listaComuni;
- }
- public void setListaComuni(ArrayList<Comune> listaComuni) {
- this.listaComuni = listaComuni;
- }
-
-
-
- @Override
- public String execute(){
-
- UnitOfWork u = new UnitOfWork();
-
- if(idp >= 0){
- listaComuni = u.GetDaoComune().getComuniByProvincia(idp);
-
- }
-
- return "SUCCESS";
- }
-
- }
this is the struts.xml
- <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="user" namespace="/User" extends="struts-default, json-default" >
<action name="checkData" class="com.mycompany.checkData">
<result type="json" />
<result name="input">registrazione.jsp</result>
<result name="SUCCESS">registrazione.jsp</result>
<result name="ERROR">registrazione.jsp</result>
</action>
</package>
</struts>