Mapping Multiple URLs to Same Controller in Spring MVC 4

April 02, 2016 | 20 views | Comments

In Spring MVC 4 Framework, the Annotation Type RequestMapping can be used to map web requests onto specific handler classes and/or handler methods. URL's can be mapped through the element value which is the primary mapping expressed by this annotation. This element is a String[] type which would allow multiple mapping to a single controller.

 

Example:

Map the URL's /index and /home to the Home controller.

@RequestMapping(value = {"/index", "/home"}, method = RequestMethod.GET)
public String Home( 

)

Result would be the links /index and /home will show the same page.

Latest Tutorials



Download and save a file from the web using JAVA


Read a file inside of JAR in JAVA


Read a file outside of JAR in JAVA


Create excel files in JAVA


Read excel files in JAVA


Install SOLR 5.x


Spring 4 MVC Multiple File Upload Example


Spring 4 MVC JSON Hello World Annotation Example


Create a File Uploader using jQuery and Bootstrap


Spring 4 MVC File Upload Example


Spring Security 4 JAVA Config In Memory Authentication Authorize Requests Security Method


Generate BCrypt Hashed Passwords using Spring Security 4


Spring Security 4 XML Config JDBC Authentication Annotation Security Method


Spring Security 4 XML Config In Memory Authentication Intercept Url Security Method


Spring Security 4 XML Config In Memory Authentication Annotation Security Method


Spring 4 MVC Hello World Annotation Example


Spring 4 MVC Hello World Bean Name Url Handler Mapping Example


Spring 4 MVC Hello World Simple Url Handler Mapping Example


Spring 4 MVC Hello World Class Name Handler Mapping Example


Generate and Configure Git SSH Key on Linux


Create a New JAVA Class on Eclipse IDE


Create a New Package on Eclipse IDE


Create a New Maven Project in Eclipse


Configure Run on Server option on a Maven Project on Eclipse IDE


Create a NodeJs Hello World example


Install NodeJs on CentOS


Integrate Maven in Eclipse


Check Apache, MySql, and PHP versions


Remove an option from a select box


Rotate an image in PHP


Select an element by name with jQuery


Check if a checkbox is checked with jQuery


Generate Random Passwords in PHP


Generate random strings using PHP


Watermark an image in PHP in four different ways


Add a text watermark using a True Type Font to an image with PHP


Add a text watermark to an image with PHP


Use imagecopymerge() to watermark an image with PHP


Watermark an image with PHP using imagecopy()


Combine a transparent PNG image on top of another image with PHP


Combine images using PHP


Write text to an image using TrueType fonts in PHP


Center a text on an image using imagestring()


Create an image with custom text in PHP


Create an image with PHP


Convert JSON to XML using PHP


Convert XML to JSON in PHP


Read XML files using jQuery


Read XML files in PHP


Create an XML file with PHP


Parse JSON file with jQuery


Parse JSON file with PHP


Create a JSON file in PHP


Know the difference between bindParam() and bindValue() in PDO


Bind a parameter to a variable using bindValue() in PDO


Bind a parameter to a variable using bindParam() in PDO


Scroll to an element using jQuery


Create a PDF file in PHP


Match the beginning of a Class or ID in jQuery


Edit an excel file using PHPExcel


Access a MySQL database from the terminal


Grant a privilege to a MySQL user on a database


Create a MySQL database user


Change font style in PHPExcel


Merge cells in PHPExcel


Change array values to lowercase or uppercase in jQuery


Check if a string is in an array in jQuery


Create an excel file in PHP


Read an excel file in PHP


Use a variable to match or replace a string in Javascript


Insert new records to a MySQL database using PDO in PHP


Update a MySQL record using PDO in PHP


Delete MySQL records using PDO in PHP


Select MySQL database records using PDO in PHP


Access MySQL database using PDO in PHP


Restore a MySQL backup file (.sql) from the terminal


Backup MySQL database into an .sql file from the terminal


Install LAMP on Ubuntu in six easy steps


Develop a Spring3 MVC Hello World Annotation Application