Skip to content

Commit 458129b

Browse files
authored
Merge pull request #6 from rainbowBPF2/bpf
Front page coding using Spring MVC
2 parents beb4dae + 8f0b95c commit 458129b

File tree

15 files changed

+602
-339
lines changed

15 files changed

+602
-339
lines changed

.idea/artifacts/greenLand_war_exploded.xml

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

.idea/artifacts/rainbow_war_exploded.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libraries/Maven__jstl_jstl_1_2.xml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 405 additions & 318 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,12 @@
9393
<version>1.8.10</version>
9494
</dependency>
9595

96+
<dependency>
97+
<groupId>jstl</groupId>
98+
<artifactId>jstl</artifactId>
99+
<version>1.2</version>
100+
</dependency>
101+
102+
96103
</dependencies>
97104
</project>

rainbow.iml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.24" level="project" />
6060
<orderEntry type="library" name="Maven: org.aspectj:aspectjrt:1.8.10" level="project" />
6161
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.8.10" level="project" />
62+
<orderEntry type="library" name="Maven: jstl:jstl:1.2" level="project" />
6263
</component>
6364
<component name="TemplatesService">
6465
<option name="TEMPLATE_FOLDERS">

src/main/java/Utility/RedisCacheImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
@Component("redisCache")
1818
public class RedisCacheImpl <V> implements RedisCache<String, V> {
1919

20-
static{
21-
PropertyConfigurator.configure("log4j.properties");
22-
}
20+
// static{
21+
// PropertyConfigurator.configure("log4j.properties");
22+
// }
2323

2424
private static Logger logger = Logger.getLogger(RedisCacheImpl.class);
2525
private final int EXPIRE_TIME = 3600 * 24;
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package controller;
2+
3+
import domain.UserInfo;
4+
import org.apache.log4j.Logger;
5+
import org.springframework.stereotype.Controller;
6+
import org.springframework.ui.ModelMap;
7+
import org.springframework.web.bind.annotation.ModelAttribute;
8+
import org.springframework.web.bind.annotation.RequestMapping;
9+
import org.springframework.web.bind.annotation.RequestMethod;
10+
import org.springframework.web.servlet.ModelAndView;
11+
12+
/**
13+
* Created by pengfei on 2017/9/22.
14+
*/
15+
@Controller
16+
public class LoginController {
17+
18+
private final static Logger logger=Logger.getLogger(LoginController.class);
19+
20+
@RequestMapping(value = "/login", method = RequestMethod.GET)
21+
public ModelAndView get(){
22+
logger.info("Inside login get method");
23+
return new ModelAndView("login","command",new UserInfo());
24+
}
25+
26+
@RequestMapping(value = "/loginHere",method=RequestMethod.POST)
27+
public String login(@ModelAttribute UserInfo user, ModelMap model){
28+
logger.info("Login controller begin service");
29+
30+
model.addAttribute("password",user.getPassword());
31+
model.addAttribute("name",user.getName());
32+
33+
if(user.getPassword()==null)
34+
throw new RuntimeException("Password should not be null!");
35+
36+
logger.info("Login controller end service!");
37+
38+
return "homePage";
39+
}
40+
41+
@RequestMapping(value="/toLoginPage",method = RequestMethod.GET)
42+
public String redirect(){
43+
return "redirect:login";
44+
}
45+
46+
@RequestMapping(value = "/visitStaticPage",method = RequestMethod.GET)
47+
public String visitStaticPage(){
48+
49+
return "redirect:/pages/static.html";
50+
}
51+
52+
53+
}

src/main/java/controller/UserController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@
1313
*/
1414

1515
@Controller
16-
@RequestMapping()
1716
public class UserController {
1817

1918
@Resource
2019
private UserService userService;
2120

2221
@RequestMapping(value = "/hello")
2322
public ModelAndView helloWorld() {
24-
ModelAndView mv = new ModelAndView("/hello");
23+
ModelAndView mv = new ModelAndView("hello");
2524
UserInfo user = userService.getUserInfo(3);
2625
mv.addObject("message", user.getComment());
2726
return mv;

src/main/java/domain/UserInfo.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ public class UserInfo {
88
private String name;
99
private double salary;
1010
private String comment;
11+
private String password;
12+
13+
public UserInfo() {
14+
15+
}
16+
17+
public UserInfo(int id, String name) {
18+
this.id = id;
19+
this.name = name;
20+
}
1121

1222
public int getId() {
1323
return id;
@@ -41,5 +51,13 @@ public void setComment(String comment) {
4151
this.comment = comment;
4252
}
4353

54+
public String getPassword() {
55+
return password;
56+
}
57+
58+
public void setPassword(String password) {
59+
this.password = password;
60+
}
61+
4462

4563
}

0 commit comments

Comments
 (0)