username password right.jsp This is my JSP page. LogAction.java //Created by MyEclipse Struts // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.eas" name="description" />

Struts+hibernate开发(源代码)(1)

发表于:2007-06-11来源:作者:点击数: 标签:
测试 页面: index.jsp java " import="java.util.*" pageEncoding="UTF-8"%> username password right.jsp This is my JSP page. LogAction.java //Created by MyEclipse Struts // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.eas

测试页面:

index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@ page language="java" import="hibernate.HibernateSessionFactory"%>

<%@ page language="java" import="mappingConfig.Admin"%>

<%@ page language="java" import="org.hibernate.HibernateException"%>

<%@ page language="java" import="org.hibernate.*"%>











username



password









right.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>



This is my JSP page.

LogAction.java

//Created by MyEclipse Struts

// XSL source (default):

platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.0.1/xslt/JavaClass.xsl

package action;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;

import org.apache.struts.action.ActionForm;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;

import form.UserForm;

import common.Com;

/**

* MyEclipse Struts

* Creation date: 03-25-2006

*

* XDoclet definition:

* @struts.action path="/log" name="userForm" input="/index.jsp"

scope="request" validate="true"

*/

public class LogAction extends Action {

// --------------------------------------------------------- Instance Variables

// --------------------------------------------------------- Methods

/**

* Method execute

* @param mapping

* @param form

* @param request

* @param response

* @return ActionForward

*/

public ActionForward execute(

ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response) {

UserForm userForm = (UserForm) form;

// TODO Auto-generated method stub

Com.execute();

return mapping.findForward("suc");

}

}

Com.java

package common;

import hibernate.HibernateSessionFactory;

import mappingConfig.Admin;

import org.hibernate.HibernateException;

import org.hibernate.Session;

import org.hibernate.Transaction;

public class Com {

public static boolean execute() {

Session session;

Transaction tx = null;

try {

session = HibernateSessionFactory.currentSession();

tx = session.beginTransaction();

Admin admin = new Admin();

admin.setName("joliny");

admin.setAge("21");

admin.setEmail("jbakwd@163.com");

admin.setPassword("2466346");

admin.setSex("man");

admin.setTelphone("13571944243");

session.save(admin);

tx.commit();

} catch (HibernateException e) {

e.printStackTrace();

}

return true;

}

//public static void main(String args[]) {

//execute();

//}

}


共4页: 1 [2] [3] [4] 下一页

原文转自:http://www.ltesting.net

评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
...