- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc.xsd
- ">
- <context:component-scan base-package="cn.hello.Conteller"></context:component-scan>
- </beans>
- @Controller
- @RequestMapping("/user")//指定的 路径名
- public class Conterller {
- @RequestMapping("/{runame}/{uage}/fist")//访问 请求 路径 携带值
- public String insert(@PathVariable("runame")String uname,@PathVariable String uage){
- System.out.println(uname);
- System.out.println(uage);
- return "/insert.jsp";
- }
- @RequestMapping("/two")
- public String delete(){
- return "/delete.jsp";
- }
- @RequestMapping("/*third")
- public String delete2(){
- //逻辑视图
- return "/delete.jsp";
- }
- @RequestMapping("/**/four")
- public String delete3(){
- return "/delete.jsp";
- }
- @RequestMapping("/*/five")
- public String delete4(){
- return "/delete.jsp";
- }
- }
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc.xsd
- ">
- <context:component-scan base-package="cn.hello.Conteller"></context:component-scan>
- </beans>
- @Controller
- public class ArgumentConterller {
- @RequestMapping("/login")
- public String login(){
- return "/index2.jsp";
- }
- @RequestMapping("/login2")
- public String login2(Useinfo info){
- System.out.println(info.getUname());
- return "/index2.jsp";
- }
- @RequestMapping("/login3")
- public String login4(@RequestParam("uname") String n){
- System.out.println(n);
- return "/index2.jsp";
- }
- @RequestMapping("/Argen")
- public String login3(Useinfo info){
- System.out.println(info.getUname()+"\t"+info.getBook().getBookName());
- return "/index2.jsp";
- }
- @RequestMapping("/ListArgen")
- public String login4(Useinfo info){
- System.out.println(info.getUname()+"\t"+info.getBooks().get(0).getBookName()+"\t"+info.getBooks().get(1).getBookName());
- return "/index2.jsp";
- }
- }
- public class Book {
- private String bookName;
- public String getBookName() {
- return bookName;
- }
- public void setBookName(String bookName) {
- this.bookName = bookName;
- }
- }
- public class Useinfo {
- private String uname;
- private Book book;
- private List<Book> books;
- public List<Book> getBooks() {
- return books;
- }
- public void setBooks(List<Book> books) {
- this.books = books;
- }
- public Book getBook() {
- return book;
- }
- public void setBook(Book book) {
- this.book = book;
- }
- public String getUname() {
- return uname;
- }
- public void setUname(String uname) {
- this.uname = uname;
- }
- }
- <%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
- <html>
- <head>
- <title>SpringMvc</title>
- </head>
- <body>
- <form action="${pageContext.request.contextPath}/ListArgen" method="post">
- 用户名:<input name="uname"/>
- 图书名1:<input name="books[0].bookName"/>
- 图书名2:<input name="books[1].bookName"/>
- <input type="submit"/>
- </form>
- </body>
- </html>