• 校验-js 页面+controller


    <%@ 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>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>添加页面</title>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/index2.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/jquery-3.2.1.js" ></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/jqueryvalidate/jquery.validate.js" ></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/jqueryvalidate/localization/messages_zh.js" ></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/jqueryvalidate/additional-methods.js" ></script>
    </head>
    <body>
    <form action="add" method="post">

    <fieldset>
    <p>
    <label for="name">姓名:</label><input name="name" id="name">
    <label for="cardid">身份证号:</label><input name="cardid" id="cardid">
    <label for="birthday">生日:</label><input name="birthday" id="birthday">
    <label for="schoold">学校:</label><input name="schoold" id="schoold">
    <label for="image">图片:</label><input name="image" id="image">
    <label for="shengid">省:</label><input name="name" id="name">
    <label for="shiid">市:</label><input name="name" id="name">
    <label for="xianid">县:</label><input name="name" id="name">

    </p>
    <p>
    <label for="schoold">学校</label>
    <select onchange="onSchoolChange()" id="schoold" name="schoold">
    <option value="0">---请选择---</option>
    <c:forEach items="${schoolList}" var="school">
    <option value="${school.id}">${school.name}</option>
    </c:forEach>
    </select>
    <label for="address">地址</label><input disabled="disabled" name="address" id="address">
    <label for="tel">电话</label><input disabled="disabled" name="tel" id="tel">
    </p>
    </fieldset>

    </form>
    </body>
    <script type="text/javascript">

    function onSchoolChange(){
    var sid = ${"#schoold"}.val();
    $.post("./getSchool",{id:sid},function(data){
    $("#address").val(data.address);
    $("#tel").val(data.tel);
    })
    }

    </script>
    </html>

    -----------------------------

    package com.lzl.controller;

    import org.apache.dubbo.config.annotation.Reference;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;

    import com.lzl.service.UserService;

    @Controller
    public class UserController {

    @Reference
    UserService service;

    @RequestMapping("validate")
    public String myvalidate() {

    return "myvalidate";

    }

    @RequestMapping("checkExist")
    @ResponseBody
    public boolean checkExist(String username) {
    return !"zhangsan".equals(username);
    }

    }

  • 相关阅读:
    C# 文本,图片 与 Base64的相互转换
    vue3.x 中的自定义组件及使用
    vue 的TodoList 小Demo
    vue中的条件渲染 v-show、v-if、v-else、v-else-if
    vue 使用$refs获取表单内容及v-model双向数据绑定
    python-异常处理&操作数据库&网络编程
    python-接口开发
    python-数据库&邮件
    python-函数和模块
    python-函数&list&dic&集合&文件读取
  • 原文地址:https://www.cnblogs.com/liuzhaolong/p/13065888.html
Copyright © 2020-2023  润新知