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
// 请注意类上定义RequestMapping,视图不以/开始
@RequestMapping("/pub/hello3")
public class Hello3Action
{
//请求/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";
}
// 请求/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";
}
// 请求/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="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<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>帮助 | 关于我们 | 使用条款 | 开放平台</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="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<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>帮助 | 关于我们 | 使用条款 | 开放平台</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="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<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>帮助 | 关于我们 | 使用条款 | 开放平台</h5>
<a href="http://localhost:8080/jxc/welcome.jsp">f_qiangqiang@qq.com</a>
</div>
</center>
</body>
</html>