registeraction.java~7~
来自「采用web2.0技术,采用动态标签,sql语句全部存储在数据库里面.开发速度快.」· JAVA~7~ 代码 · 共 65 行
JAVA~7~
65 行
package com.sztheater.biz.register;
import java.io.IOException;
import javax.servlet.ServletException;
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.ActionMapping;
import org.apache.struts.action.ActionForward;
import java.util.*;
public class RegisterAction extends Action {
protected String checkInfo(String username, String password) {
String user = username;
return user;
}
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
IOException, ServletException {
String target = new String("success");
String username = ((RegisterForm) form).getUsername();
String password = ((RegisterForm) form).getPassword();
String interest = request.getParameter("love"); //用户兴趣
((RegisterForm) form).setInterest(interest);
dealInterest(interest, username); //把用户兴趣爱好存入数据库
return (mapping.findForward(target));
}
//把用户的爱好存入数据库
public int dealInterest(String interest, String username) {
ArrayList love = new ArrayList();
if (interest.indexOf(";") < 0) {
return 0;
}
while (interest.indexOf(";") > 0) {
int i = interest.indexOf(";");
String str = interest.substring(0, i);
System.out.println(str);
love.add(str);
interest = interest.substring(i + 1);
}
for (int i = 0; i < love.size(); i++) {
// strSQL ="insert into ;
System.out.println("strSQL");
// st.executeUpdate(strSQL);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?