方槍槍的java世界

          不要因?yàn)轱L(fēng)雨飄落就停止了你的腳步,真正的得失就在你的心中。 做喜歡做的事,不輕言放棄!

          13 整合spring3和mybatis進(jìn)行web開發(fā)之Hello1Action(RequestMapping豬腳+參數(shù))

          Hello3Action.java

          package com.tianhe.app.pub.hello3.action;

          import javax.servlet.http.HttpServletRequest;

          import org.springframework.stereotype.Controller;
          import org.springframework.ui.ModelMap;
          import org.springframework.web.bind.annotation.PathVariable;
          import org.springframework.web.bind.annotation.RequestMapping;
          import org.springframework.web.bind.annotation.RequestParam;

          @Controller
          // 請(qǐng)注意類上定義RequestMapping,視圖不以/開始
          @RequestMapping("/pub/hello3")
          public class Hello3Action
          {
              //請(qǐng)求/pub/hello3/helloA/zhangsan/55.do
              //視圖pub/hello3/helloA.jsp
              @RequestMapping("/helloA/{name}/{age}")
              public String helloA(@PathVariable("name") String name, @PathVariable("age") int age)
              {
                  System.out.println("hello3.helloA");
                  return "pub/hello3/helloA";
              }
             
              // 請(qǐng)求/pub/hello3.do?service=serviceB&username=lisi&password=123456
              // 視圖pub/hello3/helloB.jsp
              @RequestMapping(params = "service=serviceB")
              public String helloB(@RequestParam("username") String username, @RequestParam("password") String password,
                      HttpServletRequest request, ModelMap map)
              {
                  System.out.println("hello3.helloB");
                  return "pub/hello3/helloB";
              }
             
              // 請(qǐng)求/pub/hello3/helloC.do?id=100
              // 視圖/pub/hello3/helloC.jsp
              @RequestMapping("helloC")
              public void helloC(@RequestParam("id") int id)
              {
                  System.out.println("hello3.helloC");
              }   
          }


          WEB-INF/pub/hello3/helloA.jsp

          <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
          <%@ taglib prefix="c" uri="<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
          <head>
          <title>天河框架案例演示</title>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
          <link type="text/css" rel="stylesheet" href="
          http://localhost:8080/jxc/skins/default/css/ngmain.css" />
          <script language=javascript src="http://localhost:8080/jxc/skins/default/js/ngcommon.js"></script>
          <script language="javascript">
          function doLogin()
          {
           document.form0.action = "<%=request.getContextPath()%>/loginAction!login.action";
           document.form0.method = "post";
           document.form0.submit();
          }
          </script>
          </head>

          <body>
          <h2>hello3.helloA</h2>

          <center>
          <div id="footer">
          <h5>幫助 | 關(guān)于我們 | 使用條款 | 開放平臺(tái)</h5>
          <a href="http://localhost:8080/jxc/welcome.jsp">f_qiangqiang@qq.com</a>
          </div>
          </center>
          </body>
          </html>



          WEB-INF/pub/hello3/helloB.jsp

          <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
          <%@ taglib prefix="c" uri="<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
          <head>
          <title>天河框架案例演示</title>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
          <link type="text/css" rel="stylesheet" href="
          http://localhost:8080/jxc/skins/default/css/ngmain.css" />
          <script language=javascript src="http://localhost:8080/jxc/skins/default/js/ngcommon.js"></script>
          <script language="javascript">
          function doLogin()
          {
           document.form0.action = "<%=request.getContextPath()%>/loginAction!login.action";
           document.form0.method = "post";
           document.form0.submit();
          }
          </script>
          </head>

          <body>
          <h2>hello3.helloB</h2>

          <center>
          <div id="footer">
          <h5>幫助 | 關(guān)于我們 | 使用條款 | 開放平臺(tái)</h5>
          <a href="http://localhost:8080/jxc/welcome.jsp">f_qiangqiang@qq.com</a>
          </div>
          </center>
          </body>
          </html>



          WEB-INF/pub/hello3/helloC.jsp

          <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
          <%@ taglib prefix="c" uri="<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
          <head>
          <title>天河框架案例演示</title>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
          <link type="text/css" rel="stylesheet" href="
          http://localhost:8080/jxc/skins/default/css/ngmain.css" />
          <script language=javascript src="http://localhost:8080/jxc/skins/default/js/ngcommon.js"></script>
          <script language="javascript">
          function doLogin()
          {
           document.form0.action = "<%=request.getContextPath()%>/loginAction!login.action";
           document.form0.method = "post";
           document.form0.submit();
          }
          </script>
          </head>

          <body>
          <h2>hello3.helloC</h2>

          <center>
          <div id="footer">
          <h5>幫助 | 關(guān)于我們 | 使用條款 | 開放平臺(tái)</h5>
          <a href="http://localhost:8080/jxc/welcome.jsp">f_qiangqiang@qq.com</a>
          </div>
          </center>
          </body>
          </html>


          posted on 2012-07-07 15:29 做強(qiáng)大的自己 閱讀(149) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 德阳市| 微博| 郓城县| 安新县| 马鞍山市| 通榆县| 梁河县| 蛟河市| 湘乡市| 金阳县| 通辽市| 兴和县| 达拉特旗| 赤峰市| 安平县| 鄂托克前旗| 淮阳县| 民权县| 尉氏县| 洞头县| 澜沧| 涪陵区| 丰城市| 浪卡子县| 阿克陶县| 田阳县| 西丰县| 岗巴县| 岳西县| 华阴市| 天长市| 沅陵县| 汾阳市| 石台县| 昌宁县| 长宁区| 民县| 玉山县| 岱山县| 开化县| 古交市|