1. 程式人生 > >SpringMVC搭建------最簡單的實現

SpringMVC搭建------最簡單的實現

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'add.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		
	    <link rel="stylesheet" type="text/css" href="<%=path %>/css/style.css">
	
     <script>
        function check(){
          var regx = /^\d+$/gi;
          var price = document.all.price.value;
          if(!regx.test(price)){
               alert("請輸入合理的資料");
               return false;
          }
          return true;
        }
     </script>
	</head>

	<body>
		<center>
		 
			<form action="<%=path%>/book/add" method="post" onsubmit="return check();">
				名稱:
				<input name="bookName" />
				<br />
				作者:
				<input name="author" />
				<br />
				單價:
				<input name="price" />
				<br />
				<Input type="submit" value="新增" />
				<input type="reset" value="取消" />
			</form>
		</center>
	</body>
</html>

最近才學現在也只是搞懂了其中的一個功能!