test spring in category
test tile
package com.journaldev.spring.controller; import java.text.DateFormat;
import java.util.Date;
import java.util.Locale; import javax.servlet.http.HttpServletRequest; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; @Controller
public class HomeController { private static final Logger logger = LoggerFactory.getLogger(HomeController.class); @RequestMapping(value = "/home", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
logger.info("Welcome home! The client locale is {}.", locale);
Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); String formattedDate = dateFormat.format(date); model.addAttribute("serverTime", formattedDate ); return "home";
} @RequestMapping(value = "/emp/get/{id}", method = RequestMethod.GET)
public String getEmployee(Locale locale, Model model,@PathVariable("id") int id) {
logger.info("Welcome user! Requested Emp ID is: "+id);
Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); String formattedDate = dateFormat.format(date); model.addAttribute("serverTime", formattedDate );
model.addAttribute("id", id);
model.addAttribute("name", "Pankaj"); return "employee";
} @RequestMapping(value="/login")
public String login(HttpServletRequest request, Model model){
return "login";
} @RequestMapping(value="/logout")
public String logout(){
return "logout";
} @RequestMapping(value="/denied")
public String denied(){
return "denied";
}
}
test spring in category的更多相关文章
- Spring学习笔记2——创建Product对象,并在其中注入一个Category对象
第一步:创建Product类.在Product类中有对Category对象的set和get方法 package com.spring.cate; public class Product { priv ...
- Spring学习笔记4——AOP
AOP 即 Aspect Oriented Program 面向切面编程 首先,在面向切面编程的思想里面,把功能分为核心业务功能,和周边功能. 所谓的核心业务,比如登陆,增加数据,删除数据都叫核心业务 ...
- Spring学习笔记3——使用注解的方式完成注入对象中的效果
第一步:修改applicationContext.xml 添加<context:annotation-config/>表示告诉Spring要用注解的方式进行配置 <?xml vers ...
- Spring学习笔记1——入门
Spring是一个基于IOC和AOP的结构J2EE系统的框架 IOC 反转控制 是Spring的基础,Inversion Of Control 简单说就是创建对象由以前的程序员自己new 构造方法来调 ...
- 面试之Spring
一.IoC IoC(Inversion of Control):控制反转(是把传统上由程序代码直接操控的对象的生成交给了容器来实现, 通过容器来实现对象组件的装配和管理.所谓"控制反转&qu ...
- spring框架学习(一)——IOC/DI
什么是Spring框架: Spring是一个基于IOC和AOP的结构J2EE系统的框架: IOC 反转控制 是Spring的基础,Inversion Of Control,简单说就是创建对象由以前的程 ...
- spring框架学习(二)——注解方式IOC/DI
什么是注解 传统的Spring做法是使用.xml文件来对bean进行注入或者是配置aop.事物,这么做有两个缺点: 1.如果所有的内容都配置在.xml文件中,那么.xml文件将会十分庞大:如果按需求分 ...
- SpringIOC/DI(2)
2019-03-08/09:24:37 开发环境:IDEA 1.创建Spring项目 File--New--project--Spring--Creat empty Spring-config.xml ...
- Spring+Mybatis基于注解整合Redis
基于这段时间折腾redis遇到了各种问题,想着整理一下.本文主要介绍基于Spring+Mybatis以注解的形式整合Redis.废话少说,进入正题. 首先准备Redis,我下的是Windows版,下载 ...
随机推荐
- eclipse界面混乱
在eclipse最右边点击Java----reset
- js对象详解
js自定义对象 一,概述 在Java语言中,我们可以定义自己的类,并根据这些类创建对象来使用,在Javascript中,我们也可以定义自己的类,例如定义User类.Hashtable类等等. 目前在J ...
- coreData部分报错:This NSPersistentStoreCoordinator has no persistent stores.
最近在修改一个程序BUG的时候遇到一个问题coreData部分报错:This NSPersistentStoreCoordinator has no persistent stores. 但实际跑程序 ...
- yii 初步安装
第一步: window下点击>开始 >运行CMD命令. 第二步:进入Yiic文件的目录 (例如在D盘里面 D:/yii/framework) 第三步:D:\yii\framework& ...
- Android添加快捷方式
private void addShortcutToDesktop() { Intent shortcut = new Intent("com.android.launcher.action ...
- JS 设计模式
1.单例模式:产生一个类的唯一实例 例如:我们在页面中添加遮罩层,每次只能有一个遮罩层存在,因此为单例模式. 在创建遮罩层之前判断是否已经存在,若没有存在,则创建. 这里使用闭包,将是mask变量封装 ...
- 关于Java中的基本数据类型转换
Java中的基本类型有四种,其中整型分为byte.short.int.long,浮点型分为float.double,字符型char,布尔型boolean.8种类型的级别由低到高byte->sho ...
- libgcc_s.so.1 must be installed for pthread_cancel to work
首先 whereis 看一下 有没有 libgcc_s.so.1 有的话 记得gcc --o xxx xxx.c -lpthread -lgcc_s
- 分享一个ruby网站 | 菜鸟教程
http://www.runoob.com/ruby/ruby-tutorial.html 分享一个ruby网站.
- 更改localhost默认打开的index.html的地址三步曲
首先说明,我的Apache安装路径是F:\software installing\Apache2.2 解释一下,localhost默认打开的是安装路径下index.html 也就是路径F:\softw ...