In my struts2 application, I have a JSP with two autocompleter fields and a submit button. The goal is when I submit, a table should be displayed in the same JSP (below the submit button) which populates data from the database (basing on the selected values of autocompleter).
I think definitely we should call some action(which goes to struts.xml and basing on the result some JSP will be shown). But, the idea is to display table in the same JSP. Can I achieve this by calling some action in a regul开发者_StackOverflow社区ar way. I am new to struts2 and can anyone help me providing a good solution.
You need to use ajax. Pass the value selected in the autocompleter to the ajax call as parameter and then you can return result list in the form of xml, json or whatever form you want.
There are many table plugins available to help displaying ajax result set in a table form. DataTables is my favourite.
For question regarding making ajax call/response in struts2 take a look here
Also, there is a struts2-jquery plugin available, you can explore that. Ihave not used it though
精彩评论