
Spring furnishes joining support with apache tiles system. So we can essentially deal with the design of the spring mvc application by the assistance of spring tiles bolster.
Favorable position of Tiles bolster in Spring MVC:
Reusability: We can reuse a solitary part in numerous pages like header and footer segments.
Centralized control: We can control the format of the page by a solitary layout page as it were.
Spring MVC Tiles
Required Jar files
- Spring Core jar files
- Spring Web jar files
- Tiles jar files
Controller classes
HelloWorldController.javapackage com.javatpoint.controller;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.servlet.ModelAndView;@Controllerpublic class HelloWorldController {@RequestMapping("/hello")public ModelAndView helloWorld() {String message = "Hello World, Spring MVC @ Javaspot";return new ModelAndView("hello", "message", message);}}ContactController.javapackage com.javaspot.controller;import org.springframework.stereotype.Controller;import org.springframework.validation.BindingResult;import org.springframework.web.bind.annotation.ModelAttribute;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.SessionAttributes;import org.springframework.web.servlet.ModelAndView;import com.javaspot.form.Contact;@Controller@SessionAttributespublic class ContactController {@RequestMapping(value = "/addContact", method = RequestMethod.POST)public String addContact(@ModelAttribute("contact") Contact contact, BindingResult result) {//write the code here to add contactreturn "redirect:contact.html";}@RequestMapping("/contact")public ModelAndView showContacts() {return new ModelAndView("contact", "command", new Contact());}}Form class
Contact.javapackage com.javaspot.form;public class Contact {private String firstname;private String lastname;private String email;private String telephone;//getters and setters}web.xmlRemoting in Spring
Spring structure makes the development of remote-empowered administrations simple. It spares a considerable measure of code by giving its own particular API.
Preferred standpoint of Spring RemotingThe software engineer needs to focus on business rationale just not plumbing exercises, for beginning and halting the server.
Spring system underpins following remoting advancements
- Remote Method Invocation (RMI)
- Spring's HTTP invoker
- Hessian
- Burlap
- JAX-RPC (J2EE 1.4 API)
- JAX-WS (Java EE 5 and Java EE 6 API)
- JMS
Spring and RMI Integration
Spring RMI gives you a chance to uncover your administrations through the RMI framework. Spring gives a simple approach to run RMI application by the assistance of
org.springframework.remoting.rmi.RmiProxyFactoryBean org.springframework.remoting.rmi.RmiServiceExporterclasses.
RmiServiceExporter
It gives the exportation administration to the rmi protest. This administration can be gotten to by means of plain RMI or RmiProxyFactoryBean.
RmiProxyFactoryBean
It is the production line bean for Rmi Proxies. It uncovered the proxied benefit that can be utilized as a bean reference.And Combination of the resources in a spring is with a RMI proxyFactory Bean.
Spring Remoting by HTTP Invoker
Spring gives its own execution of remoting administration known as HttpInvoker. It can be utilized for http ask for than RMI and functions admirably over the firewall.
By the assistance of HttpInvokerServiceExporter and HttpInvokerProxyFactoryBean classes, we can execute the remoting administration gave by Spring's Http Invokers.
Http Invoker and Other Remoting procedures
You can utilize numerous Remoting strategies, how about we see which one can be best for you.
Http Invoker Vs RMI
RMI utilizes JRMP convention though Http Invokes utilizes HTTP convention. Since big business applications generally utilize http convention, it is the better to utilize HTTP Invoker. RMI additionally has some security issues than HTTP Invoker. HTTP Invoker functions admirably crosswise over firewalls.
Http Invoker Vs Hessian and Burlap
HTTP Invoker is the piece of Spring system yet Hessian and burlap are exclusive. All functions admirably crosswise over firewall. Hessian and Burlap are convenient to coordinate with different dialects, for example, .Net and PHP yet HTTP Invoker can't be.
Spring Remoting by Hessian Example
By the assistance of HessianServiceExporter and HessianProxyFactoryBean classes, we can execute the remoting administration gave by hessian.Favorable position of HessianHessian functions admirably crosswise over firewall. Hessian is convenient to coordinate with different dialects, for example, PHP and .Net.
Example of Remoting by Hessian
- Calculation.java
- CalculationImpl.java
- web.xml
- hessian-servlet.xml
- client-beans.xml
- Client.java
- . serviceUrl
- serviceInterface
