Skip to content

Commit 797cef8

Browse files
committed
Dynamic URL Resouce Loading Added, WebApp Context-Path Added.
1 parent 3b05207 commit 797cef8

File tree

5 files changed

+108
-61
lines changed

5 files changed

+108
-61
lines changed

src/main/java/guru/springframework/domain/Interest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.hibernate.validator.constraints.Email;
1010
import org.springframework.data.annotation.Id;
1111
import org.springframework.data.mongodb.core.mapping.Document;
12+
import org.springframework.data.mongodb.core.mapping.Field;
1213

1314
@Document(collection = "interest")
1415
public class Interest {

src/main/java/guru/springframework/utils/KeyGenerator.java

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package guru.springframework.utils;
22

3+
import java.util.HashSet;
34
import java.util.Random;
5+
import java.util.Set;
46

57
public class KeyGenerator {
6-
private static String allCharacters = "0123456789abcdefghijklmnopqrstuvwxyz";
8+
private static String allCharacters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
79

810
public static String getKey() {
911
Random rand = new Random();
@@ -16,4 +18,40 @@ public static String getKey() {
1618

1719
}
1820

21+
public static String getKey(int keyLength) {
22+
Random rand = new Random();
23+
String key = "";
24+
for (int i = 0; i < keyLength; i++) {
25+
int index = rand.nextInt(allCharacters.length());
26+
key += allCharacters.substring(index, index + 1);
27+
}
28+
return key;
29+
30+
}
31+
32+
// public static void main(String[] args) {
33+
// System.out.println("Started!");
34+
// long startTime = System.currentTimeMillis();
35+
// Set genes = new HashSet();
36+
// int keys = 1000000;
37+
// while (true) {
38+
//
39+
// for (int i = 0; i < keys; i++) {
40+
// String key = KeyGenerator.getKey(10);
41+
// genes.add(key);
42+
// }
43+
//
44+
// if (keys != genes.size()) {
45+
// break;
46+
// }
47+
// genes = new HashSet();
48+
// }
49+
// long endTime = System.currentTimeMillis();
50+
// long elapsedTime = endTime-startTime;
51+
// System.out.println("Ended!");
52+
// System.out.println("Time: " + elapsedTime);
53+
//
54+
//
55+
// }
56+
1957
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
server.port=15001
1+
server.port=15001
2+
server.context-path=/mongo

src/main/resources/templates/create.html

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,25 @@
1111
<link
1212
href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&amp;subset=all"
1313
rel="stylesheet" type="text/css" />
14-
<link href="/metro/font-awesome/css/font-awesome.min.css"
14+
<link th:href="@{/metro/font-awesome/css/font-awesome.min.css}"
1515
rel="stylesheet" type="text/css" />
16-
<link href="/metro/bootstrap/css/bootstrap.min.css" rel="stylesheet"
17-
type="text/css" />
18-
<link href="/metro/bootstrap-switch/css/bootstrap-switch.min.css"
16+
<link th:href="@{/metro/bootstrap/css/bootstrap.min.css}"
17+
rel="stylesheet" type="text/css" />
18+
<link th:href="@{/metro/bootstrap-switch/css/bootstrap-switch.min.css}"
1919
rel="stylesheet" type="text/css" />
20-
<link rel="stylesheet" type="text/css" href="/metro/select2/select2.css" />
2120
<link rel="stylesheet" type="text/css"
22-
href="/metro/datatables/plugins/bootstrap/dataTables.bootstrap.css" />
21+
th:href="@{/metro/select2/select2.css}" />
22+
<link rel="stylesheet" type="text/css"
23+
th:href="@{/metro/datatables/plugins/bootstrap/dataTables.bootstrap.css}" />
2324

2425

25-
<link href="/metro/css/components.css" id="style_components"
26+
<link th:href="@{/metro/css/components.css}" id="style_components"
2627
rel="stylesheet" type="text/css" />
27-
<link href="/metro/css/plugins.css" rel="stylesheet" type="text/css" />
28-
<link href="/metro/layout2/css/layout.css" rel="stylesheet"
28+
<link th:href="@{/metro/css/plugins.css}" rel="stylesheet"
2929
type="text/css" />
30-
<link id="style_color" href="/metro/layout2/css/themes/grey.css"
30+
<link th:href="@{/metro/layout2/css/layout.css}" rel="stylesheet"
31+
type="text/css" />
32+
<link id="style_color" th:href="@{/metro/layout2/css/themes/grey.css}"
3133
rel="stylesheet" type="text/css" />
3234

3335
<link rel="shortcut icon" href="favicon.ico" />
@@ -64,33 +66,36 @@
6466

6567
<div class="form-body">
6668
<div class="form-group form-md-line-input">
67-
<label th:if="${#fields.hasErrors('name')}" style="color:red;"
68-
th:errors="*{name}">Name fields error</label> <input
69-
type="text" class="form-control" th:field="*{name}"
70-
id="name" name="name" /> <label for="name">Name</label>
69+
<label th:if="${#fields.hasErrors('name')}"
70+
style="color: red;" th:errors="*{name}">Name fields
71+
error</label> <input type="text" class="form-control"
72+
th:field="*{name}" id="name" name="name" /> <label
73+
for="name">Name</label>
7174
</div>
7275
<div class="form-group form-md-line-input">
73-
<label th:if="${#fields.hasErrors('email')}" style="color:red;"
74-
th:errors="*{email}">Email fields error</label> <input
75-
type="text" class="form-control" th:field="*{email}"
76-
id="email" name="email" /> <label for="email">Email</label>
76+
<label th:if="${#fields.hasErrors('email')}"
77+
style="color: red;" th:errors="*{email}">Email
78+
fields error</label> <input type="text" class="form-control"
79+
th:field="*{email}" id="email" name="email" /> <label
80+
for="email">Email</label>
7781

7882

7983
</div>
8084
<div class="form-group form-md-line-input">
81-
<label th:if="${#fields.hasErrors('batch')}" style="color:red;"
82-
th:errors="*{batch}">Batch fields error</label> <input
83-
type="text" class="form-control" id="batch"
84-
th:field="*{batch}" name="batch" /> <label for="batch">Batch</label>
85+
<label th:if="${#fields.hasErrors('batch')}"
86+
style="color: red;" th:errors="*{batch}">Batch
87+
fields error</label> <input type="text" class="form-control"
88+
id="batch" th:field="*{batch}" name="batch" /> <label
89+
for="batch">Batch</label>
8590

8691

8792
</div>
8893
<div class="form-group form-md-line-input">
8994
<label th:if="${#fields.hasErrors('interested')}"
90-
th:errors="*{interested}" style="color:red;">Interested fields error</label> <input
91-
type="text" class="form-control" th:field="*{interested}"
92-
id="interested" name="interested" /> <label
93-
for="interested">Interested</label>
95+
th:errors="*{interested}" style="color: red;">Interested
96+
fields error</label> <input type="text" class="form-control"
97+
th:field="*{interested}" id="interested" name="interested" />
98+
<label for="interested">Interested</label>
9499
</div>
95100
</div>
96101
<div class="form-actions noborder">
@@ -108,21 +113,23 @@
108113
</div>
109114
</div>
110115

111-
<script src="/metro/jquery.min.js" type="text/javascript"></script>
112-
<script src="/metro/jquery-migrate.min.js" type="text/javascript"></script>
113-
<script src="/metro/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
114-
<script src="/metro/bootstrap/js/bootstrap.min.js"
116+
<script th:src="@{/metro/jquery.min.js}" type="text/javascript"></script>
117+
<script th:src="@{/metro/jquery-migrate.min.js}" type="text/javascript"></script>
118+
<script th:src="@{/metro/jquery-ui/jquery-ui.min.js}"
119+
type="text/javascript"></script>
120+
<script th:src="@{/metro/bootstrap/js/bootstrap.min.js}"
115121
type="text/javascript"></script>
116-
<script src="/metro/jquery.blockui.min.js" type="text/javascript"></script>
117-
<script src="/metro/bootstrap-switch/js/bootstrap-switch.min.js"
122+
<script th:src="@{/metro/jquery.blockui.min.js}" type="text/javascript"></script>
123+
<script th:src="@{/metro/bootstrap-switch/js/bootstrap-switch.min.js}"
118124
type="text/javascript"></script>
119-
<script type="text/javascript" src="/metro/select2/select2.min.js"></script>
120125
<script type="text/javascript"
121-
src="/metro/datatables/media/js/jquery.dataTables.min.js"></script>
126+
th:src="@{/metro/select2/select2.min.js}"></script>
127+
<script type="text/javascript"
128+
th:src="@{/metro/datatables/media/js/jquery.dataTables.min.js}"></script>
122129
<script type="text/javascript"
123-
src="/metro/datatables/extensions/TableTools/js/dataTables.tableTools.min.js"></script>
130+
th:src="@{/metro/datatables/extensions/TableTools/js/dataTables.tableTools.min.js}"></script>
124131
<script type="text/javascript"
125-
src="/metro/datatables/plugins/bootstrap/dataTables.bootstrap.js"></script>
126-
<script src="/metro/pages/scripts/table-advanced.js"></script>
132+
th:src="@{/metro/datatables/plugins/bootstrap/dataTables.bootstrap.js}"></script>
133+
<script th:src="@{/metro/pages/scripts/table-advanced.js}"></script>
127134
</body>
128135
</html>

src/main/resources/templates/index.html

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@
1111
<link
1212
href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&amp;subset=all"
1313
rel="stylesheet" type="text/css" />
14-
<link href="/metro/font-awesome/css/font-awesome.min.css"
14+
<link th:href="@{/metro/font-awesome/css/font-awesome.min.css}"
1515
rel="stylesheet" type="text/css" />
16-
<link href="/metro/bootstrap/css/bootstrap.min.css" rel="stylesheet"
16+
<link th:href="@{/metro/bootstrap/css/bootstrap.min.css}" rel="stylesheet"
1717
type="text/css" />
18-
<link href="/metro/bootstrap-switch/css/bootstrap-switch.min.css"
18+
<link th:href="@{/metro/bootstrap-switch/css/bootstrap-switch.min.css}"
1919
rel="stylesheet" type="text/css" />
20-
<link rel="stylesheet" type="text/css" href="/metro/select2/select2.css" />
20+
<link rel="stylesheet" type="text/css" th:href="@{/metro/select2/select2.css}" />
2121
<link rel="stylesheet" type="text/css"
22-
href="/metro/datatables/plugins/bootstrap/dataTables.bootstrap.css" />
22+
th:href="@{/metro/datatables/plugins/bootstrap/dataTables.bootstrap.css}" />
2323

2424

25-
<link href="/metro/css/components.css" id="style_components"
25+
<link th:href="@{/metro/css/components.css}" id="style_components"
2626
rel="stylesheet" type="text/css" />
27-
<link href="/metro/css/plugins.css" rel="stylesheet" type="text/css" />
28-
<link href="/metro/layout2/css/layout.css" rel="stylesheet"
27+
<link th:href="@{/metro/css/plugins.css}" rel="stylesheet" type="text/css" />
28+
<link th:href="@{/metro/layout2/css/layout.css}" rel="stylesheet"
2929
type="text/css" />
30-
<link id="style_color" href="/metro/layout2/css/themes/grey.css"
30+
<link id="style_color" th:href="@{/metro/layout2/css/themes/grey.css}"
3131
rel="stylesheet" type="text/css" />
3232

3333
<link rel="shortcut icon" href="favicon.ico" />
@@ -82,8 +82,8 @@
8282
<td th:id="'${info.batch}'+'-batch'" th:text="${info.batch}"></td>
8383
<td th:id="'${info.interested}'+'-interested'"
8484
th:text="${info.interested}"></td>
85-
<td><a th:href="${'/interest/edit/'+info.id}">Edit</a></td>
86-
<td><a th:href="${'/interest/delete/'+info.id}">Delete</a></td>
85+
<td><a th:href="@{${'/interest/edit/'+info.id}}">Edit</a></td>
86+
<td><a th:href="@{${'/interest/delete/'+info.id}}">Delete</a></td>
8787
</tr>
8888
</tbody>
8989

@@ -97,22 +97,22 @@
9797
</div>
9898
</div>
9999

100-
<script src="/metro/jquery.min.js" type="text/javascript"></script>
101-
<script src="/metro/jquery-migrate.min.js" type="text/javascript"></script>
102-
<script src="/metro/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
103-
<script src="/metro/bootstrap/js/bootstrap.min.js"
100+
<script th:src="@{/metro/jquery.min.js}" type="text/javascript"></script>
101+
<script th:src="@{/metro/jquery-migrate.min.js}" type="text/javascript"></script>
102+
<script th:src="@{/metro/jquery-ui/jquery-ui.min.js}" type="text/javascript"></script>
103+
<script th:src="@{/metro/bootstrap/js/bootstrap.min.js}"
104104
type="text/javascript"></script>
105-
<script src="/metro/jquery.blockui.min.js" type="text/javascript"></script>
106-
<script src="/metro/bootstrap-switch/js/bootstrap-switch.min.js"
105+
<script th:src="@{/metro/jquery.blockui.min.js}" type="text/javascript"></script>
106+
<script th:src="@{/metro/bootstrap-switch/js/bootstrap-switch.min.js}"
107107
type="text/javascript"></script>
108-
<script type="text/javascript" src="/metro/select2/select2.min.js"></script>
108+
<script type="text/javascript" th:src="@{/metro/select2/select2.min.js}"></script>
109109
<script type="text/javascript"
110-
src="/metro/datatables/media/js/jquery.dataTables.min.js"></script>
110+
th:src="@{/metro/datatables/media/js/jquery.dataTables.min.js}"></script>
111111
<script type="text/javascript"
112-
src="/metro/datatables/extensions/TableTools/js/dataTables.tableTools.min.js"></script>
112+
th:src="@{/metro/datatables/extensions/TableTools/js/dataTables.tableTools.min.js}"></script>
113113
<script type="text/javascript"
114-
src="/metro/datatables/plugins/bootstrap/dataTables.bootstrap.js"></script>
115-
<script src="/metro/pages/scripts/table-advanced.js"></script>
114+
th:src="@{/metro/datatables/plugins/bootstrap/dataTables.bootstrap.js}"></script>
115+
<script th:src="@{/metro/pages/scripts/table-advanced.js}"></script>
116116

117117
<script>
118118
jQuery(document).ready(function() {

0 commit comments

Comments
 (0)