Paulius Matulionis
Paulius Matulionis

Reputation: 23415

Spring MVC navigation

I want to create simple navigation with Spring MVC, so far I got this:

@Controller
@RequestMapping("/secure")
public class NavigationController {

    @ModelAttribute("myPath/operation")
    public OperationForm getOperationForm() {
        return new OperationForm();
    }

    @RequestMapping("/myPath/operation")
    public String processOperationPage() {
        //Some logic goes here
        return "myPath/operation";
    }

    @ModelAttribute("myPath/configuration")
    public ConfigurationForm getConfigurationForm() {
        return new ConfigurationForm();
    }

    @RequestMapping("/myPath/configuration")
    public String processConfigurationPage(Map model) {
        return "myPath/configuration";
    }

}

And in my JSP page:

<a href="${pageContext.servletContext.contextPath}/secure/myPath/configuration.htm" class="parent">Configuration</a>
<a href="${pageContext.servletContext.contextPath}/secure/myPath/operation.htm" class="parent">Operation</a>

Is this solution for navigating through pages efficient? Could you suggest me some other ways to make the navigation? I am sure there is but I can't find anything on the internet.

Upvotes: 2

Views: 2104

Answers (1)

NimChimpsky
NimChimpsky

Reputation: 47290

For the jsp's this is a bit neater imho :

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
...

<c:url var="config" value="/secure/myPath/configuration.htm"/>

<a href="${config}" class="parent">Configuration</a>

Upvotes: 1

Related Questions