- Load application Context on Spring?
- ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
- Autowired
- @Autowired
- private ApplicationContext appContext;
- Spring bean scopes: session and globalSession
- GlobalSession is something which is connected to Portlet applications. When your application works in Portlet container it is built of some amount of portlets. Each portlet has its own session, but if your want to store variables global for all portlets in your application than you should store them in globalSession. This scope doesn't have any special effect different from session scope in Servlet based applications.
- What is the difference between a portlet and a servlet?
- Portlets are part of JSR-168 standard that regulates portal containers and components. This is different standard from standards for web containers (and servlets). Though there are definitely strong parallels between these two standards they differ in containers, APIs, life cycle, configuration, deployment, etc.
- The main difference between portlet vs. servlet could be that while servlet always responds to single type of action - request, portlet (due to nature of its life cycle and stronger container bindings) has to respond to two types of actions: render and request. There are of course more to it but I found this as the core difference between the two when I studied portal development.
- Difference between spring @Controller and @RestController annotation?
@Controller
- @Controller is used to mark classes as Spring MVC Controller.
- If we need to return values as JSON or XML then need to add @ResponseBody annotation above the method
@RestController
- Its methods will automatically converte the response to JSON or XML.
No need to add @ResponseBody annotation.
@Controller
@ResponseBody
public class MyController { }
@RestController
public class MyRestController { }
No comments:
Post a Comment