Spring Boot : Custom Validation in Request Params

Case 1: If the annotation ValuesAllowed is not triggered at all, it could be because of not annotating the controller with @Validated. @Validated @ValuesAllowed(propName = “orderBy”, values = { “OpportunityCount”, “OpportunityPublishedCount”, “ApplicationCount”, “ApplicationsApprovedCount” }) public class OpportunityController { @GetMapping(“/vendors/list”) public String getVendorpage(@RequestParam(required = false) String term,..{ } Case 2: If it is triggered and throwing … Read more

Spring MVC – Why not able to use @RequestBody and @RequestParam together

The @RequestBody javadoc states Annotation indicating a method parameter should be bound to the body of the web request. It uses registered instances of HttpMessageConverter to deserialize the request body into an object of the annotated parameter type. And the @RequestParam javadoc states Annotation which indicates that a method parameter should be bound to a … Read more

How to programmatically send POST request to JSF page without using HTML form?

I understand that you’re basically asking how to submit a JSF form programmatically using some HTTP client such as java.net.URLConnection or Apache HttpComponents Client, right? You need to send a GET request first and make sure that you maintain the same HTTP session (basically, the JSESSIONID cookie) across requests. Let your HTTP client extract the … Read more

HTTP request parameters are not available by request.getAttribute()

Here, String url = (String) request.getAttribute(“url”); you’re trying to get a request parameter as a request attribute instead of as a request parameter. This will obviously not do what you want. You need to get a request parameter as a request parameter, not as a request attribute. String url = request.getParameter(“url”); Unrelated to the concrete … Read more

What is difference between @RequestBody and @RequestParam?

@RequestParam annotated parameters get linked to specific Servlet request parameters. Parameter values are converted to the declared method argument type. This annotation indicates that a method parameter should be bound to a web request parameter. For example Angular request for Spring RequestParam(s) would look like that: $http.post(‘http://localhost:7777/scan/l/register?username=”Johny”&password=”123123″&auth=true’) .success(function (data, status, headers, config) { … }) … Read more

Retaining GET request query string parameters on JSF form submit

Your concrete problem is caused because a JSF <h:form> submits by default to the current request URL without any query string. Look closer at the generated HTML output, you’ll see <form action=”/app/agreement.xhtml” …> You’d thus explicitly need to include those request parameters yourself. There are several ways to solve this. If you weren’t sending a … Read more

How do I process GET query string URL parameters in backing bean on page load?

Yes, you can use the <f:viewParam> to set a request parameter as a managed bean property. <f:metadata> <f:viewParam name=”companyId” value=”#{bean.companyId}” /> </f:metadata> You can if necessary invoke a bean action using <f:viewAction> (JSF 2.2+ only) or <f:event type=”preRenderView”>. <f:metadata> <f:viewParam name=”companyId” value=”#{bean.companyId}” /> <f:viewAction action=”#{bean.onload}” /> </f:metadata> When using <f:viewAction> you can even return a … Read more