jsp form表单代码如下。
引用
<div class="pannelbody">
<div class="pannellist">
<form id="useradd" name="useradd" action="UserInseAction" method="post">
<label for="username">名称:</label>
<input name="username" type="text" id="username" value="" size="30" class="colorblue" onFocus="this.className='colorfocus';" onBlur="this.className='colorblue';" />
<br />
<label for="nickname">昵称:</label>
<input name="nickname" type="text" id="nickname" value="" size="30" class="colorblue" onFocus="this.className='colorfocus';" onBlur="this.className='colorblue';" />
<br />
<label for="password">密码:</label>
<input name="password" type="password" id="password" value="" size="30" class="colorblue" onFocus="this.className='colorfocus';" onBlur="this.className='colorblue';" />
<br />
<label for="sex">性别:</label>
<select name="sex" id="sex" class="colorblue">
<option value="0">女</option><option value="1">男</option><option value="9">人妖</option>
</select>
<br />
<label for="birthday">生日:</label>
<input name="birthday" type="text" id="birthday" value="" size="30" class="colorblue Wdate" onFocus="this.className='colorfocus';WdatePicker({startDate:'1985-07-01'});" onBlur="this.className='colorblue';" />
<br />
<label for="remark">备注:</label>
<textarea name="remark" cols="50" rows="6" id="remark" class="colorblue" onFocus="this.className='colorfocus';" onBlur="this.className='colorblue';" style="width:80%;"></textarea>
<br />
<!---字段较多,省略一些个--->
<label for=""></label>
<input name="status" type="hidden" value="1" />
<input name="button" type="submit" class="sbutton" id="button" value="提交"/>
<input name="button2" type="reset" class="sbutton" id="button2" value="返回" />
</form>
</div>
Struts.xml的配置
引用
<?xml version="1.0" encoding="gbk" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" namespace="/" extends="struts-default">
<action name="*">
<result>/WEB-INF/jsp/{1}.jsp</result>
</action>
<action name="UserInseAction" class="com.lcsz.classmates.action.UserInfoAction">
<!-- result name="success" type="redirect">login</result-->
<result name="success" type="redirect">login</result>
<result name="input" type="redirect">UserIns</result>
</action>
</package>
</struts>
UserInfoAction.java 代码
引用
package com.lcsz.classmates.action;
import com.lcsz.classmates.dao.UserDao;
import com.lcsz.classmates.dao.impl.UserDaoImpl;
import com.lcsz.classmates.pojo.User;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
public class UserInfoAction extends ActionSupport implements ModelDriven<User> {
/**
* long
*/
private static final long serialVersionUID = 1L;
public User user = new User();
public String execute(){
UserDao userdao = new UserDaoImpl();
try {
if (userdao.UserIns(user)) {
return SUCCESS;
} else {
return INPUT;
}
} catch (Exception e) {
System.out.println("发现错误:"+e.getMessage());
return INPUT ;
}
}
public User getModel() {
return user;
}
}
在数据库中的插入记录 中文的话就是null 英文和数字可以插入进行
- 大小: 73.9 KB
分享到:
相关推荐
NULL 博文链接:https://cdxs2.iteye.com/blog/1925245
NULL 博文链接:https://huangminwen.iteye.com/blog/1828698
NULL 博文链接:https://vzhchv0010.iteye.com/blog/388889
NULL 博文链接:https://lf6627926.iteye.com/blog/1513041
NULL 博文链接:https://mvplee.iteye.com/blog/2240323
NULL 博文链接:https://arne3166.iteye.com/blog/775152
NULL 博文链接:https://tianhandigeng.iteye.com/blog/995031
NULL 博文链接:https://ihuning.iteye.com/blog/2233463
NULL 博文链接:https://ewf-momo.iteye.com/blog/1708697
NULL 博文链接:https://namas.iteye.com/blog/1130854
在使用struts标签html:checkbox 的时候,如何让... 注:如果不选中,最好把Property的设置为””,因为在Action中得到Property是为null值,在不太注意的情况,它是会出现异常。 代码如下: public class CheckBoxF
NULL 博文链接:https://cdxs2.iteye.com/blog/1931337
NULL 博文链接:https://12345678.iteye.com/blog/711024
NULL 博文链接:https://yy5664729.iteye.com/blog/2275782
将用户信息保存到Session中。 Map, Object> session = ActionContext.getContext().getSession(); session.put("userName", userName); session.put("passWord", passWord); // 2. taglib标识传递 resultMsg =...
NULL 博文链接:https://coderdream.iteye.com/blog/812871
struts实现数据库添删改查,以及分页 ArrayList<Users> list; UserService service; Users user; Pager page=new Pager(); public Pager getPage() { return page; } public void setPage(Pager page) { ...
自己在struts2中的写好了业务逻辑用response返回的内容却是一个页面的! 然后就去了百度一下,说的是将struts2的返回值设为null(return null),这是因为struts2返回的是一个页面。如果在action中只进行业务逻辑不...
NULL 博文链接:https://takeme.iteye.com/blog/1663039
在Ajax更新复习次数时通常都会第一次失败,再点一次就能成功了,第一次失败是因为Request 取到了NULL值,因为对三大框架无缝组合还不太熟悉,如果你知识别忘了告诉我哦(yukiceo@126.com) 由于对页面样式了解不多...