Skip to content

Instantly share code, notes, and snippets.

@php-coder
Last active December 12, 2015 04:08
DRY with URLs
<form:form action="/series/add" method="post" modelAttribute="addSeriesForm">
...
</form:form>
driver.get("http://localhost/series/add");
<a href="/series/add">Добавить серию</a>
<%@ page import="ru.mystamps.web.Url" %>
<spring:url var="addSeriesUrl" value="<%= Url.ADD_SERIES_PAGE %>" />
<a href="${addSeriesUrl}">Добавить серию</a>
@RequestMapping(value = "/series/add", method = RequestMethod.GET)
public AddSeriesForm showForm() {
...
}
@RequestMapping(value = "/series/add", method = RequestMethod.POST)
public String processInput(@Valid AddSeriesForm form, BindingResult result) {
...
}
return "series/add";
@RequestMapping(value = Url.ADD_SERIES_PAGE, method = RequestMethod.GET)
public AddSeriesForm showForm() {
...
}
<intercept-url pattern="/series/add" access="hasRole('ROLE_USER')" />
<definition name="series/add" extends="defaultTemplate">
<put-attribute name="title" value="Добавить серию" />
<put-attribute name="body" value="/WEB-INF/tiles/body/series/add.jsp" />
</definition>
public final class Url {
public static final String ADD_SERIES_PAGE = "/series/add";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment