Struts 2 select tag with values of a array list

The error “The requested list key ‘departmentlist’ could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} – [unknown location] “ means that the select tag is not able to resolve departmentlist as a collection. It is an OGNL expression which is trying to find the departmentlist in the value stack and if … Read more

How to submit multiple Line Items in Struts 2?

you was almost there. Just change the Javascript part where you assign the name attribute, including the index exactly as you do in the iteration: item.name=”id.item”; specification.name=”id.specification”; // ecc… must become item.name=”id[“+counts+”].itemname”; specification.name=”id[“+counts+”].specification”; And you will be good.

Make ${} operator XSS safe in Struts 2 (same as tapestry)

Struts2 <s:property value=”name” /> is automatically escaped by default; JSTL <c:out value=”${name}” /> is automatically escaped by default; JSP EL ${name} is NOT escaped. You can explicitly escape it with ${fn:escapeXml(name)} , or set the escape to be performed by default creating a custom ELResolver as described in this great article: ELResolver Escapes JSP EL … Read more

Upload multiple files in Struts2 with Dropzone.js

Problem When you use <input type=”file” name=”file” multiple /> the files will all be sent with name=”file”, eg: Content-Disposition: form-data; name=”file”; filename=”foo.jpg” Content-Type: image/jpeg ……….. . … ……. Content-Disposition: form-data; name=”file”; filename=”bar.jpg” Content-Type: image/jpeg …. . .. ……. and this is the right parameter Struts2 FileUpload Interceptor is expecting to receive, to work with a … Read more

Advanced Wildcard Mappings Parameters not found in Prepare() method

That parameters are not set by the ParametersInterceptor (like those coming from the JSP), but by the StaticParametersInterceptor.To have them filled in the prepare() method, the same trick of the paramsPrepareParamsStack must be applied. Since there is not an Interceptor Stack that does that out-of-the-box, you must define it.Starting from the defaultStack, we should create … Read more

Whitelist security constraint in web.xml

I would try the following: <security-constraint> <web-resource-collection> <url-pattern>/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <!– no auth-constraint tag here –> </security-constraint> <security-constraint> <web-resource-collection> <web-resource-name>restricted methods</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint/> </security-constraint> The first security-constraint does not have any auth-constraint, so the GET and POST methods are available to anyone without login. The second restricts other http methods for everybody. (I … Read more