Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue#7 #16

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package net._4programmers._4note.controllers;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class IndexController {
@RequestMapping("/")
public String index() {
return "index";
public String index(Model model) {
model.addAttribute("container", "index.ftl");
return "template";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ public class UsersController {
@RequestMapping("/user/{userId}")
public String getUser(@PathVariable int userId, Model model){
User user = userDao.getUserById(userId);

if(user == null) {
return "redirect:/";
}

model.addAttribute("user", userDao.getUserById(userId));

return "user";
model.addAttribute("user", user);
model.addAttribute("container", "user.ftl");
return "template";
}
}
3 changes: 2 additions & 1 deletion src/main/webapp/WEB-INF/application-context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<context:component-scan base-package="net._4programmers._4note" />

<mvc:annotation-driven />
<mvc:resources mapping="/resources/**" location="/resources/"/>

<tx:annotation-driven />

Expand Down Expand Up @@ -47,7 +48,7 @@
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/test" />
<property name="username" value="root" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can not change configuration like that, we need to figure it out how to store that localy

<property name="password" value="pass" />
<property name="password" value="maciek" />
</bean>

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
Expand Down
10 changes: 5 additions & 5 deletions src/main/webapp/WEB-INF/views/index.ftl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
<h1>4Notes</h1>
<p>This is an example of 4Notes homepage</p>
<p>
<a class="btn btn-lg btn-success" role="button">Action</a>
</p>
47 changes: 47 additions & 0 deletions src/main/webapp/WEB-INF/views/template.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>4Note</title>

<link href="/resources/bootstrap-3.3.2-dist/css/bootstrap.min.css" rel="stylesheet">
<link href="/resources/css/custom-styles.css" rel="stylesheet">
</head>

<body>

<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">4Notes</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div>
</div>
</nav>


<div class="container">
<div class="jumbotron">
<#include "${container}">
</div>
</div>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="/resources/bootstrap-3.3.2-dist/js/bootstrap.min.js"></script>
</body>
</html>
7 changes: 2 additions & 5 deletions src/main/webapp/WEB-INF/views/user.ftl
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
<html>
<body>
<h2>Hej ${user.getUsername()}</h2>
</body>
</html>
<h1>Hello, ${user.getUsername()}!</h1>
<p>Here is your email: ${user.getEmail()}</p>
Loading