📄 searchaction.java
字号:
package action;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import org.apache.struts.upload.FormFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletException;
import javax.imageio.ImageIO;
import java.io.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.sql.ResultSet;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import com.sun.image.codec.jpeg.JPEGCodec;
import formbean.SearchForm;
import beans.DataBean;
import beans.PageBean;
/**
* Created by IntelliJ IDEA.
* User: Administrator
* Date: 2006-6-22
* Time: 15:51:56
* To change this template use File | Settings | File Templates.
*/
public class SearchAction extends Action {
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
request.setCharacterEncoding("GBK");
response.setContentType("text/html;charset=gbk");
SearchForm searchForm = (SearchForm)form;
String searchtext = new String(searchForm.getSearchtext().getBytes("ISO-8859-1") );
String pictype = new String(searchForm.getPictype().getBytes("ISO-8859-1") );
PageBean pb = new PageBean();
if(!searchForm.getSearchtext().equals("") && !pictype.equals("all")){
String sql = "select id,name,type,pos,detail from pictures where detail like '%"+searchtext+"%' and typecon like '"+pictype+"'" ;
pb.getResult(sql);
}
if(searchForm.getSearchtext().equals("") && !pictype.equals("all")){
String sql = "select id,name,type,pos,detail from pictures where typecon like '"+pictype+"'" ;
pb.getResult(sql);
}
if(!searchForm.getSearchtext().equals("") && pictype.equals("all")){
String sql = "select id,name,type,pos,detail from pictures where detail like '%"+searchtext+"%'" ;
pb.getResult(sql);
}
if(searchForm.getSearchtext().equals("") && pictype.equals("all")){
String sql = "select id,name,type,pos,detail from pictures" ;
pb.getResult(sql);
}
HttpSession session =request.getSession();
session.setAttribute("pagebean",pb);
return mapping.findForward("success");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -