#SpringMVC中的响应:一个简单的例子 @FDDLC

    科技2022-07-11  95

    先放流程图:

     

     

     

     

     

    index.jsp:

    <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <body> <a href="test?name=Tom">test</a> </body> </html>

     

    success.jsp:

    <%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %> <html> <head> <title>Title</title> </head> <body> <h3>获取name的方式1:${requestScope.name}</h3> <h3>获取name的方式2:${name}</h3> </body> </html>

     

    HelloController.java:

    package cn.liuxingchang.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class HelloController { @RequestMapping("/test") public String test(String name, Model model) { model.addAttribute("name", name); return "success"; } }

     

    Processed: 0.009, SQL: 8