Form submit in Spring MVC 3 – explanation

The @ModelAttribute annotation in this case is used to identify an object that Spring should add as a model attribute. Model attributes are an abstraction from the HttpServletRequest attributes. Basically, they are objects identified by some key that will find their way into the HttpServletRequest attributes. You can do this by manually adding an attribute … Read more

What is the meaning of {id:.+} in a Spring MVC requestmapping handler method?

The syntax of a path variable in a spring MVC controller requestmapping is {variable_name:regular_expression}. You can optionally omit the regular expression, which leads to what you see more often, {id}. So, for the example /index/{endpoint}/{type}/{id:.+} the variable name is id and the regular expression is .+ (see below reference to spring docs). The regular expression … Read more

How exactly are the root context and the dispatcher servlet context into a Spring MVC web application?

Root Context The root-context in a Spring application is the ApplicationContext that is loaded by the ContextLoaderListener. This context should have globally available resources like services, repositories, infrastructure beans (DataSource, EntityManagerFactorys etc.) etc. The ContextLoaderListener registers this context in the ServletContext under the name org.springframework.web.context.WebApplicationContext.ROOT. If you load an ApplicationContext yourself and register it with … Read more

How to disable csrf in Spring using application.properties?

As the WebSecurityConfigurerAdapter uses an imperative approach you can inject the value of the security.enable-csrf variable and disable CSRF when it be false. You are right, I think this should work out of the box. @Configuration public class AuthConfig extends WebSecurityConfigurerAdapter { @Autowired private UserDetailsService userDetailsService; @Value(“${security.enable-csrf}”) private boolean csrfEnabled; @Override protected void configure(AuthenticationManagerBuilder auth) … Read more

Spring AOP pointcut that matches annotation on interface

If I understand you correct, you want a pointcut that finds all methods in classes that extends MyService and is annotated and with the preferred arguments. I propose that you replace: execution(public * com.mycompany.myserviceimpl.*(..)) with: execution(public * com.mycompany.myservice.MyService+.*(..)) The plus sign is used if you want a joinpoint to match the MyService class or a … Read more

SPRING REST: The request was rejected because no multipart boundary was found

The problem isn’t in your code – it’s in your request. You’re missing boundary in your multipart request. As it said in specification: The Content-Type field for multipart entities requires one parameter, “boundary”, which is used to specify the encapsulation boundary. The encapsulation boundary is defined as a line consisting entirely of two hyphen characters … Read more

Unable to get a generic ResponseEntity where T is a generic class “SomeClass”

This was a known issue. Now it’s fixed with the introduction of ParameterizedTypeReference, which is a parameterized type that you explicitely inherit to supply type information at runtime. This is called a super-type token, and works around type erasure because subclasses (anoniymous in this case) keep the type arguments of the generic supertype at runtime. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)