急!求教onclick后如何调用一个函数 把数据传回数据库?

xybgmg xybgmg 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我在写一个注册页面
下边是jsp的部分代码
<div align="center">
<form id="ff" method="post" action="reg">
<table cellpadding="5">
<tr>
<td>用户名:</td>
<td><input class="easyui-textbox" type="text" name="userName" data-options="required:true"></input></td>
</tr>
<tr>
<td>密码:</td>
<td><input class="easyui-textbox" type="password" name="userPass" data-options="required:true"></input></td>
</tr>
<tr>
<td>生日:</td>
<td><input class="easyui-textbox" type="text" name="birthday" data-options="required:true"></input></td>
</tr>
<tr>
<td>邮箱:</td>
<td><input class="easyui-textbox" type="text" name="email" data-options="required:true,validType:'email'"></input></td>
</tr>

</table>
<div style="text-align:center;padding:20px">
<div style="text-align:center;padding:20px">
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="<%return Reg()%>">Submit</a>        
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()">Clear</a>
</div>

我希望按完submit后 就能把注册信息传回数据库 该怎么写" onclick="<%return Reg()%>">Submit</a> 部分呢?怎么调用下边那个函数?我已经反转了hibernate
下面是Reg.java
import com.operate.UserinfoOperate;

public class Reg extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

this.doPost(request, response);
}

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

String userName = request.getParameter("userName");
String userPass = request.getParameter("userPass");
String birthday = request.getParameter("birthday");
String email = request.getParameter("email");

try {
UserinfoOperate.addUser(userName, userPass, birthday, email);
} catch (ParseException e) {
e.printStackTrace();
}

response.getWriter().print("success registered");
}

...全文

相关推荐

Spring boot + thymeleaf 后端直接给onclick函数赋值的实现代码

主要介绍了Spring boot + thymeleaf 后端直接给onclick函数赋值的实现代码,需要的朋友可以参考下

weixin_38651286

jsp中调用js中的一个函数,函数传参的问题

NULL 博文链接:https://youzhibing.iteye.com/blog/2166047

weixin_38669628

JavaScript onclick事件使用方法详解

onclick是一个事件,当事件被触发时就会执行处理,onclick是一个处理鼠标点击的事件。本篇文章就给大家分享关于JavaScript中onclick事件的用法。 我们首先来看一下onclick事件的语法 以下是如何使用onclick事件编写。 使用document.getElementById()在文档中指定id元素,并使用function(){}处理单击该元素时发生的事件。 document.getElementById("button").onclick = function() { // 设置在此处单击#button时要发生的事件 }; 我们来看具体的示例 以下是使用oncl

weixin_38688403

怎么通过onclick事件获取js函数返回值(代码少)

主要介绍了怎么通过onclick事件获取js函数返回值,需要的朋友可以参考下

weixin_38514523

如何在 HTML 中调用 JavaScript 函数而不使用 onclick.docx

JavaScript 一度被视为网络 3 个核心技术之一,现在几乎可以在任何可以找到代码的地方找到它。JavaScript 开发人员快速行动并推动软件开发向前发展;他们可能和他们使用的框架一样固执己见,所以让我们保持这里的干净,让它成为一个互相学习的地方!

Q shen
评论 2
收藏 已收藏
分享
返回顶部
xybgmg
JavaScript 87,984 成员 224,680 内容