SpringMVC
CodeBoyWLC
技术+原理爱好者
展开
-
【SpringMVC】标签库:errors
@Controllerpublic class MyController { @RequestMapping(value="/result") public String registerForm(Model model){ User user = new User(); model.addAttribute("user", user); return "result"; } @InitBinder public void initBinder(DataBinder binder)原创 2021-05-20 13:22:27 · 144 阅读 · 0 评论 -
【SpringMVC】标签库:select
@Controllerpublic class MyController { @RequestMapping(value="/click",method=RequestMethod.GET) public String selectForm(Model model) { User user= new User(); user.setDeptId(2); model.addAttribute("user", user); return "result"; }}<%@原创 2021-05-20 13:21:13 · 270 阅读 · 0 评论 -
【SpringMVC】标签库:radiobutton、radiobuttons
@Controllerpublic class MyController { @RequestMapping(value = "/click", method = RequestMethod.GET) public String registerForm(Model model) { User user = new User(); user.setSex("男"); model.addAttribute("user", user); return "result"; }}原创 2021-05-20 13:20:10 · 125 阅读 · 0 评论 -
【SpringMVC】标签库:checkbox、checkboxes
@Controllerpublic class MyController { @RequestMapping(value = "/click") public String registerForm(Model model) { User user = new User(); List<String> list = new ArrayList<String>(); list.add("JAVAEE"); list.add("Spring"); user原创 2021-05-20 13:18:54 · 277 阅读 · 0 评论 -
【SpringMVC】标签库:pasword标签、hidden、textarea
<tr> <td>姓名:</td> <td><form:password path="username"/></td> </tr><td><form:hidden path="username"/></td><td><form:textarea path="username" rows="5" cols="20"/>...原创 2021-05-20 13:17:22 · 148 阅读 · 0 评论 -
【SpringMVC】标签库:form标签、input标签
@Controllerpublic class MyController { @RequestMapping(value = "/click") public String registerForm(Model model) { User user = new User("xiaom", "男", 28); model.addAttribute("command", user); return "result"; }}<%@ page language="java".原创 2021-05-20 13:15:16 · 139 阅读 · 0 评论 -
【SpringMVC】@ModelAttribute
方式一 @ModelAttribute("loginname") public String userModel1(@RequestParam("loginname") String loginname) { return loginname; } @RequestMapping(value = "/click") public String loginl() { return "result"; }方式二 @ModelAttribute public void userMo原创 2021-05-20 13:11:06 · 55 阅读 · 0 评论 -
【SpringMVC】@CookieValue
@RequestMapping(value="/cookieValueTest") public void cookieValueTest( @CookieValue(value="JSESSIONID", defaultValue="") String sessionId){ logger.info("@CookieValue,通过@CookieValue获数据:" + sessionId); }原创 2021-05-19 21:57:28 · 85 阅读 · 0 评论 -
【SpringMVC】请求方法,用User对象绑定,请求的各参数值
@Controller@RequestMapping(value="/us") public class MyController { @RequestMapping(value="/click",method = RequestMethod.POST) public String hello2(User user){ System.out.println(":"+user); return "result"; } }package domain;publi原创 2021-05-19 21:56:36 · 103 阅读 · 0 评论 -
【SpringMVC】@RequestHeader
@RequestMapping(value="/requestHeaderTest") public void requestHeaderTest( @RequestHeader(value="Accept-Language") String s1, @RequestHeader("User-Agent")String userAgent, @RequestHeader(value="Accept")String[] accepts) { logger.info("@Re.原创 2021-05-19 21:55:02 · 99 阅读 · 0 评论 -
【SpringMVC】REST:基于REST的4种请求
package controller;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;原创 2021-05-19 21:54:07 · 99 阅读 · 0 评论 -
【SpringMVC】@PathVariable
@RequestMapping(value = "/loginF/{name}",method = RequestMethod.GET) public void fun( @PathVariable("name") String name , Model model){ model.addAttribute("name",name); System.out.println("fun执行"); }原创 2021-05-19 21:52:51 · 78 阅读 · 0 评论 -
【SpringMVC】@RequestParam
@RequestMapping(value="/loginF") public ModelAndView fun(@RequestParam("name")String name){ ModelAndView mv = new ModelAndView(); mv.setViewName("success"); mv.addObject("msg", name); return mv; }http://localhost:6666/mySpr..原创 2021-05-19 21:51:47 · 61 阅读 · 0 评论 -
【SpringMVC】ModelAndView
package controller;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.springframewo原创 2021-05-19 21:50:22 · 71 阅读 · 0 评论 -
【SpringMVC】重定向:forward:、redirect:
两者作用一致package controller;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;@Controller@RequestMapping(value="/us") public class MyController { @RequestMapping("/click") public St原创 2021-05-19 21:47:37 · 106 阅读 · 0 评论 -
【SpringMVC】自定义视图解析器
package controller;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.PathVa.原创 2021-05-19 21:46:27 · 115 阅读 · 0 评论 -
【SpringMVC】Hello World程序
package controller;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;@Controllerpublic class MyController { @RequestMapping("/click") public String hello(){ System.out.println("hello .原创 2021-05-19 21:44:58 · 65 阅读 · 0 评论 -
Spring MVC的Servlet.init() for servlet [Main] threw exception异常
异常原因:jar包版本过低解决方法:下载最新版本、所有jar包版本要尽可能一致原创 2020-07-26 10:33:29 · 153 阅读 · 0 评论 -
Spring MVC错误:No mapping found for HTTP request with URI
原因①:springmvc-config.xml内< property>的value配置错误解决:确保*.jsp与配置的路径一样若是No mapping found for HTTP request with URI [/项目名/]:则需通过浏览器URL访问原创 2020-07-27 14:51:51 · 333 阅读 · 0 评论