How to access values ​​from dynaaction form in jsp

we can set the attributes in the servlet, and we can get these values ​​in jsp by accessing the get attribute. Like we have something access to values ​​in jsp. For example, Form DynaActionForm home = (DynaActionForm); String age = (String) home.get ("age"); I want to access this age in jsp.

Please help me solve this problem. Thanks

+3
source share
3 answers

You can add a map of your form to the request area as follows:

        Map m = dynaform.getMap();
    request.setAttribute("mapForm", m);

And then go into the jsp properties with:

${mapForm['nameOfYourFormProperty'] }

It uses JSTL. Otherwise, you can use this:

<%= ((Map)request.getAttribute("mapForm")).get("nameOfYourFormProperty") %>
+1
source

, DynaActionForm Struts View (jsp)?

DynaActionForm Action Struts:

DynaActionForm myForm = (DynaActionForm) form;
request.setAttribute("myForm", myForm);

JSP DynaActionForm - :

DynaActionForm myForm = (DynaActionForm) request.getAttribute("myForm");
String age = (String) myForm.get("var");

Struts .

0

struts-config.xml , , , bean: write tag.

0

Source: https://habr.com/ru/post/1733506/


All Articles