2

我想用 Spring MVC 创建简单的导航,到目前为止我得到了这个:

@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";
    }

}

在我的 JSP 页面中:

<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>

这种浏览页面的解决方案是否有效?你能给我一些其他的导航方法吗?我确定有,但我在互联网上找不到任何东西。

4

1 回答 1

1

对于jsp,这有点整洁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>
于 2012-09-26T12:06:34.657 回答