java sring mvc 及页面提交传参

时间:2019-02-23 08:41:14
【文件属性】:

文件名称:java sring mvc 及页面提交传参

文件大小:18KB

文件格式:RAR

更新时间:2019-02-23 08:41:14

sts spring mvc

非常 简单的鸽子使用开发环境 sts 适合不需要配置什么,tomcat也可以加进来, package ghy.webapp.myapp; import java.text.DateFormat; import java.util.Date; import java.util.Locale; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; /** * Handles requests for the application home page. */ @Controller public class HomeController { private static final Logger logger = LoggerFactory.getLogger(HomeController.class); /** * Simply selects the home view to render by returning its name. */ @RequestMapping(value = "/", 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 = "/Two", method = RequestMethod.GET) public String Two( int id,Model model ) { logger.info("two"); System.out.println("hello2 action:"+id); model.addAttribute("name", "huangjie"); //这个只有值没有键的情况下,使用Object的类型作为key,String-->string model.addAttribute("ok"); return "Two"; } }


【文件预览】:
HelloSpringMVC
----.project(1KB)
----.springBeans(366B)
----src()
--------test()
--------main()
----target()
--------m2e-wtp()
--------classes()
--------test-classes()
----.settings()
--------org.eclipse.wst.common.project.facet.core.xml(222B)
--------org.eclipse.m2e.core.prefs(86B)
--------org.eclipse.wst.ws.service.policy.prefs(87B)
--------org.eclipse.jdt.core.prefs(723B)
--------org.eclipse.wst.validation.prefs(2KB)
--------org.springframework.ide.eclipse.beans.core.prefs(8KB)
--------org.eclipse.core.resources.prefs(191B)
--------org.eclipse.wst.common.component(646B)
--------org.springframework.ide.eclipse.core.prefs(11KB)
----pom.xml(5KB)
----.classpath(1KB)

网友评论