📄 newuseraction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.my.struts.action;
import java.io.UnsupportedEncodingException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
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 com.my.dao.UserDao;
import com.my.hibernate.User;
import com.my.struts.form.NewuserForm;
/**
* MyEclipse Struts
* Creation date: 12-23-2008
*
* XDoclet definition:
* @struts.action path="/newuser" name="newuserForm" input="/newuser.jsp" scope="request" validate="true"
*/
public class NewuserAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
* @throws UnsupportedEncodingException
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
NewuserForm newuserForm = (NewuserForm) form;// TODO Auto-generated method stub
HttpSession session=request.getSession(false);
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
User user=new User();
UserDao dao=new UserDao();
String username=new String(newuserForm.getUsername().getBytes("ISO8859-1"),"utf-8");
user.setUsername(username);
String password=newuserForm.getPassword();
user.setPassword(password);
float emoney=newuserForm.getEmoney();
user.setEmoney(emoney);
//String money;
// user.setMoney(money);
String type=new String(newuserForm.getType().getBytes("ISO8859-1"),"utf-8");;
user.setType(type);
try{
dao.insert(user);
}catch(Exception e){
e.printStackTrace();
}
return mapping.findForward("success");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -