zoukankan      html  css  js  c++  java
  • SpringMVC 使用Form标签库制作登录表单

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>SpringMVC</title>
    <link href="style/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript">
    
    	function refreshVcode(){
    		document.getElementById("vcode").src="images/vcode.jpg?r="+Math.random();
    	}
    
    </script>
    </head>
    <body>
    										<!-- 对象要和表单绑定,把对象传递过来 -->
    	 <form:form action="" method="post" commandName="form">
    	 <tr>
    	 	<td>登录名:</td>
    	 	<td>
    	 		<form:input path="loginName" />
    	 	</td>
    	 </tr>
    	 <tr>
    	 	<td>密码:</td>
    	 	<td>
    	 		<form:password path="password" />
    	 	</td>
    	 </tr>
    	 <tr>
    	 	<td></td>
    	 	<td>
    	 		<input type="submit" value="登陆"/>
    	 	</td>
    	 </tr>
    	 
    	 </form:form>
    </body>
    </html>
    
    ublic class LoginController {
    	//方法的返回值返回一个对象
    	@ModelAttribute("form")
    	public LoginForm getForm(){
    		return new LoginForm();
    	}
    	
    	//我发送请求要访问login.html页面
    	
    	@RequestMapping(value="login",method=RequestMethod.GET)
    	public String showLogin(){
    		
    		return "login";
    	}
    
  • 相关阅读:
    基础知识概要
    文件操作
    排序
    python 内置函数
    lambda表达式
    函数
    字典dict
    Session、Cookie 学习笔记
    Spring+MVC+Mybatis整合
    JSONP原理解析
  • 原文地址:https://www.cnblogs.com/Angelinas/p/5637997.html
Copyright © 2011-2022 走看看