Skip to content

Commit 6e5c696

Browse files
committed
Renamed URLs at site to getting rid from extension.
/site/index.htm -> / /site/maintenance.htm -> /site/maintenance /account/register.htm -> /account/register /account/auth.htm -> /account/auth /account/activate.htm -> /account/activate /account/logout.htm -> /account/logout /stamps/add.htm -> /stamps/add /country/add.htm -> /country/add /password/restore.htm -> /password/restore /error/404.htm -> /error/404 Also /account/auth.htm?key=123 now changed to /account/auth/key/123 Fixed #88
1 parent 89a7a6b commit 6e5c696

File tree

8 files changed

+41
-37
lines changed

8 files changed

+41
-37
lines changed

src/main/java/ru/mystamps/web/SiteMap.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,27 @@ public final class SiteMap {
3232
public static final String SITE_URL = "http://127.0.0.1:8081";
3333

3434
// defined at src/main/resources/spring/DispatcherServletContext.xml
35-
public static final String INDEX_PAGE_URL = "/site/index.htm";
36-
public static final String MAINTENANCE_PAGE_URL = "/site/maintenance.htm";
35+
public static final String INDEX_PAGE_URL = "/";
36+
public static final String MAINTENANCE_PAGE_URL = "/site/maintenance";
3737

38-
public static final String REGISTRATION_PAGE_URL = "/account/register.htm";
39-
public static final String AUTHENTICATION_PAGE_URL = "/account/auth.htm";
40-
public static final String ACTIVATE_ACCOUNT_PAGE_URL = "/account/activate.htm";
41-
public static final String LOGOUT_PAGE_URL = "/account/logout.htm";
38+
public static final String REGISTRATION_PAGE_URL = "/account/register";
39+
public static final String AUTHENTICATION_PAGE_URL = "/account/auth";
40+
public static final String ACTIVATE_ACCOUNT_PAGE_URL = "/account/activate";
4241

43-
public static final String ADD_STAMPS_PAGE_URL = "/stamps/add.htm";
42+
public static final String
43+
ACTIVATE_ACCOUNT_PAGE_WITH_KEY_URL = "/account/activate/key/{key}";
4444

45-
public static final String ADD_COUNTRY_PAGE_URL = "/country/add.htm";
45+
public static final String LOGOUT_PAGE_URL = "/account/logout";
46+
47+
public static final String ADD_STAMPS_PAGE_URL = "/stamps/add";
48+
49+
public static final String ADD_COUNTRY_PAGE_URL = "/country/add";
4650

4751
// defined at src/main/resources/spring/DispatcherServletContext.xml
48-
public static final String RESTORE_PASSWORD_PAGE_URL = "/password/restore.htm";
52+
public static final String RESTORE_PASSWORD_PAGE_URL = "/password/restore";
4953

5054
// see also error-page definition at src/main/webapp/WEB-INF/web.xml
51-
public static final String NOT_FOUND_PAGE_URL = "/error/404.htm";
55+
public static final String NOT_FOUND_PAGE_URL = "/error/404";
5256

5357
private SiteMap() {
5458
}

src/main/java/ru/mystamps/web/controller/ActivateAccountController.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@
1818

1919
package ru.mystamps.web.controller;
2020

21+
import java.util.Map;
22+
2123
import javax.validation.Valid;
2224

2325
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
2426
import org.springframework.beans.factory.annotation.Autowired;
2527
import org.springframework.stereotype.Controller;
2628
import org.springframework.web.bind.annotation.InitBinder;
29+
import org.springframework.web.bind.annotation.PathVariable;
2730
import org.springframework.web.bind.annotation.RequestMapping;
2831
import org.springframework.web.bind.annotation.RequestMethod;
29-
import org.springframework.web.bind.annotation.RequestParam;
3032
import org.springframework.web.bind.WebDataBinder;
3133
import org.springframework.validation.BindingResult;
3234

@@ -35,9 +37,9 @@
3537
import ru.mystamps.web.validation.ActivateAccountValidator;
3638

3739
import static ru.mystamps.web.SiteMap.ACTIVATE_ACCOUNT_PAGE_URL;
40+
import static ru.mystamps.web.SiteMap.ACTIVATE_ACCOUNT_PAGE_WITH_KEY_URL;
3841

3942
@Controller
40-
@RequestMapping(ACTIVATE_ACCOUNT_PAGE_URL)
4143
public class ActivateAccountController {
4244

4345
private final UserService userService;
@@ -58,17 +60,22 @@ protected void initBinder(final WebDataBinder binder) {
5860
binder.registerCustomEditor(String.class, "name", new StringTrimmerEditor(false));
5961
}
6062

61-
@RequestMapping(method = RequestMethod.GET)
62-
public ActivateAccountForm showForm(
63-
@RequestParam(value = "key", required = false, defaultValue = "")
64-
final String activationKey) {
63+
@RequestMapping(value = ACTIVATE_ACCOUNT_PAGE_URL, method = RequestMethod.GET)
64+
public ActivateAccountForm showForm() {
65+
return new ActivateAccountForm();
66+
}
67+
68+
@RequestMapping(value = ACTIVATE_ACCOUNT_PAGE_WITH_KEY_URL, method = RequestMethod.GET)
69+
public String showForm(@PathVariable("key") final String activationKey, final Map model) {
6570

6671
final ActivateAccountForm form = new ActivateAccountForm();
6772
form.setActivationKey(activationKey);
68-
return form;
73+
model.put("activateAccountForm", form);
74+
75+
return "account/activate";
6976
}
7077

71-
@RequestMapping(method = RequestMethod.POST)
78+
@RequestMapping(value = ACTIVATE_ACCOUNT_PAGE_URL, method = RequestMethod.POST)
7279
public String processInput(
7380
@Valid final ActivateAccountForm form,
7481
final BindingResult result) {

src/main/resources/spring/DispatcherServletContext.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
</bean>
2626

2727
<mvc:annotation-driven />
28-
28+
<mvc:default-servlet-handler />
2929
<mvc:resources mapping="/static/**" location="/WEB-INF/static/*" />
3030

3131
<!-- see also src/ru/mystamps/web/SiteMap.java -->
32-
<mvc:view-controller path="/site/index.htm" view-name="site/index" />
33-
<mvc:view-controller path="/site/maintenance.htm" view-name="site/maintenance" />
34-
<mvc:view-controller path="/password/restore.htm" view-name="password/restore" />
32+
<mvc:view-controller path="/" view-name="site/index" />
33+
<mvc:view-controller path="/site/maintenance" view-name="site/maintenance" />
34+
<mvc:view-controller path="/password/restore" view-name="password/restore" />
3535

3636
<import resource="database.xml" />
3737

src/main/webapp/WEB-INF/pages/account/activate.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</span>
2121
</div>
2222
<div class="generic_form">
23-
<form:form method="post" modelAttribute="activateAccountForm">
23+
<form:form method="post" action="${activateUrl}" modelAttribute="activateAccountForm">
2424
<table>
2525
<tr>
2626
<td>

src/main/webapp/WEB-INF/segments/std.jspf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
44
<%@ page import="ru.mystamps.web.SiteMap" %>
55
<spring:url var="authUrl" value="<%= SiteMap.AUTHENTICATION_PAGE_URL %>" />
6+
<spring:url var="activateUrl" value="<%= SiteMap.ACTIVATE_ACCOUNT_PAGE_URL %>" />
67
<spring:url var="logoutUrl" value="<%= SiteMap.LOGOUT_PAGE_URL %>" />
78
<spring:url var="registerUrl" value="<%= SiteMap.REGISTRATION_PAGE_URL %>" />
89
<spring:url var="restorePasswordUrl" value="<%= SiteMap.RESTORE_PASSWORD_PAGE_URL %>" />

src/main/webapp/WEB-INF/web.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
-->
3939
<error-page>
4040
<error-code>404</error-code>
41-
<location>/error/404.htm</location>
41+
<location>/error/404</location>
4242
</error-page>
4343

4444
<filter>
@@ -58,7 +58,7 @@
5858

5959
<filter-mapping>
6060
<filter-name>MaintenanceFilter</filter-name>
61-
<url-pattern>*.htm</url-pattern>
61+
<url-pattern>/*</url-pattern>
6262
</filter-mapping>
6363

6464
<filter>
@@ -74,7 +74,7 @@
7474

7575
<filter-mapping>
7676
<filter-name>CharsetFilter</filter-name>
77-
<url-pattern>*.htm</url-pattern>
77+
<url-pattern>/*</url-pattern>
7878
</filter-mapping>
7979

8080
</web-app>

src/main/webapp/index.html

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/test/java/ru/mystamps/web/tests/cases/WhenUserActivateAccount.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import static ru.mystamps.web.validation.ValidationRules.PASSWORD_MIN_LENGTH;
3939
import static ru.mystamps.web.validation.ValidationRules.ACT_KEY_LENGTH;
4040

41-
import static ru.mystamps.web.SiteMap.ACTIVATE_ACCOUNT_PAGE_URL;
41+
import static ru.mystamps.web.SiteMap.ACTIVATE_ACCOUNT_PAGE_WITH_KEY_URL;
4242
import static ru.mystamps.web.SiteMap.AUTHENTICATION_PAGE_URL;
4343

4444
@RunWith(SpringJUnit4ClassRunner.class)
@@ -67,8 +67,9 @@ public void shouldHaveStandardStructure() {
6767
@Test
6868
public void activationKeyShouldBeAutoFilledFromURL() {
6969
final String key = "7777744444";
70+
final String url = ACTIVATE_ACCOUNT_PAGE_WITH_KEY_URL.replace("{key}", key);
7071

71-
page.open(ACTIVATE_ACCOUNT_PAGE_URL + "?key=" + key);
72+
page.open(url);
7273
assertThat(page.getFieldValue("activationKey")).isEqualTo(key);
7374

7475
page.open();

0 commit comments

Comments
 (0)