javascript - How to make jQuery function executable with Spring MVC? -
i have spring project values interval jquery function doesn't work. new jquery , ajax , don't know how fix it.
this controller class:
@controller public class chooseform { @requestmapping(value = "/choose", method = requestmethod.get) public modelandview selectvalue() { try{ file file = new file("c:/program files/apache software foundation/tomcat 8.0/tmpfiles/canon.xml"); jaxbcontext jaxbcontext = jaxbcontext.newinstance(canon.class); unmarshaller jaxbunmarshaller = jaxbcontext.createunmarshaller(); canon canon = (canon) jaxbunmarshaller.unmarshal(file); list<table> table = canon.gettable(); for(table tables: table){ list<string> row = tables.getrow(); list<string> first = new arraylist<string>(); list<string> second = new arraylist<string>(); list<string> third = new arraylist<string>(); list<string> fourth = new arraylist<string>(); list<string> fifth = new arraylist<string>(); list<string> sixth = new arraylist<string>(); list<string> seventh = new arraylist<string>(); list<string> 8 = new arraylist<string>(); list<string> ninth = new arraylist<string>(); list<string> tenth = new arraylist<string>(); string values = null; string values2 = null; string value1 = null; string value2 = null; string value3 = null; string value4 = null; string value5 = null; string value6 = null; string value7 = null; string value8 = null; string value9 = null; string value10 = null; string value11 = null; string value22 = null; string value33 = null; string value44 = null; string value55 = null; string value66 = null; string value77 = null; string value88 = null; string value99 = null; string value1010 = null; list<string> rowss = row.sublist(0, 12600); for(int i=0; i<rowss.size(); i++){ values = row.get(i); string[] parts = values.split(" +"); string part0 = parts[1]; string part1 = parts[2]; string part2 = parts[3]; string part3 = parts[4]; string part4 = parts[5]; string part5 = parts[6]; string part6 = parts[7]; string part8 = parts[8]; string part9 = parts[9]; string part10 = parts[10]; value1 = parts[1]; value2 = parts[2]; value3 = parts[3]; value4 = parts[4]; value5 = parts[5]; value6 = parts[6]; value7 = parts[7]; value8 = parts[8]; value9 = parts[9]; value10 = parts[10]; first.add(value1); second.add(value2); third.add(value3); fourth.add(value4); fifth.add(value5); sixth.add(value6); seventh.add(value7); eight.add(value8); ninth.add(value9); tenth.add(value10); } list<string> row1 = tables.getrow(); list<string> rows = row1.sublist(12600, row1.size()); for(int j=0; j<rows.size(); j++){ values2 = rows.get(j); string[] parts2 = values2.split(" +"); string part11 = parts2[0]; string part22 = parts2[1]; string part33 = parts2[2]; string part44 = parts2[3]; string part55 = parts2[4]; string part66 = parts2[5]; string part77 = parts2[6]; string part88 = parts2[7]; string part99 = parts2[8]; string part1010 = parts2[9]; value11 = parts2[0]; value22 = parts2[1]; value33 = parts2[2]; value44 = parts2[3]; value55 = parts2[4]; value66 = parts2[5]; value77 = parts2[6]; value88 = parts2[7]; value99 = parts2[8]; value1010 = parts2[9]; first.add(value11); second.add(value22); third.add(value33); fourth.add(value44); fifth.add(value55); sixth.add(value66); seventh.add(value77); eight.add(value88); ninth.add(value99); tenth.add(value1010); } modelandview model = new modelandview("chooseform"); model.addobject("first", first); model.addobject("second", second); model.addobject("third", third); model.addobject("fourth", fourth); model.addobject("fifth", fifth); model.addobject("sixth", sixth); model.addobject("seventh", seventh); model.addobject("eight", eight); model.addobject("ninth", ninth); model.addobject("tenth", tenth); return model; } } catch (jaxbexception e) { e.printstacktrace(); } return null; } }
my jsp file jquery function is:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <html> <head> <title>filter form</title> </head> <body> <center> <form> <p>first value:</p> <form:label path="first" id="firstvalue" /> <input type="text" id="first" /> <br/>last value: <br/> <form:label path="first" id="lastvalue" /> <input type="text" id="second" /> <br/> <input type="submit" id="btnsubmit" value="submit" /> </form> </center> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"> $(document).ready(function () { $('#btnsubmit').on("click", function () { var array = ${first}; var newarray = []; var firstval = $('#first').val(); var lastval = $('#second').val(); (var i=0; i<array.length;i++) { if (array[i] >= firstval && array[i] <= lastval) { newarray.push(array[i]); // add new array } } // loop through new array , display values (var i=0; i<newarray.length;i++) { alert(newarray[i]); } }); }) </script> </body> </html>
here want values first list<string>
${first}, when enter values , click on submit button, gives me nothing. can me that?
Comments
Post a Comment