icats 0 Newbie Poster

Hello!

I could do this in Struts 1 but can't for the life of me figure out how to do this in struts 2!!! Basically, data I posted as a JS array would come into the action as a String array, but now nothing comes in and "myCars is null".

Thanks for any help in advance!!!!!

Action Code:

public class LookAtCarsAction{
       public String execute() {

		if ( getMyCars() != null) {
			for ( int i = 0; i < getMyCars().length; i++) {
				log.info("myCars: " + myCars[i]);
			}
		} else {
			log.info("myCars is null");
		}
		return SUCCESS;	
	}

	private String[] myCars;	

	public void setMyCars(String[] myCars) {
		this.myCars = myCars;
	}
	public String[] getMyCars() {
		return myCars;
	}
}

javascript:

$.post("${pageContext.request.contextPath}/lookAtCars.action",
{ 
	myCars: ["mazda, porsch"]		
},
function(data)
{  	    					
	//do stuff
	if ( data != "" ) {
		alert("ROCK ON");
	}
	else {

	}
	return false;
}, 
"html");