📄 searchform.java
字号:
package com.yhbbs.article.search.form;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
/**
* <p>Title:论坛搜索Form</p>
* <br>根据用户输入条件,开始搜索
* <br><b>WebSite: www.yyhweb.com</b>
* <br><b>CopyRight: yyhweb[由由华网]</b>
* @author stephen
* @version YHBBS-2.0
*/
public class SearchForm extends ActionForm{
private static final long serialVersionUID = 1L;
/** 搜索关键字 */
private String keyword = "";
/** 搜索作者还是搜索帖子 0:作者 1:帖子 */
private int authorpost = 0;
/** 发帖用户 0:主题贴作者 1:回复贴作者 2:两者都有 */
private int author = 0;
/** 搜索帖子标题还是内容 0:标题 1:内容 2:两者都有 */
private int content = 0;
/** 搜索时间范围 */
private int postdate = 0;
/** 搜索论坛Id */
private int schfmId = 0;
/**
* @return 搜索用户类型
*/
public int getAuthor() {
return author;
}
/** 设置搜索用户类型
* @param author 用户类型
*/
public void setAuthor(int author) {
this.author = author;
}
/**
* @return 是搜索作者还是搜索帖子
*/
public int getAuthorpost() {
return authorpost;
}
/** 是搜索作者还是搜索帖子
* @param authorpost 搜索选型
*/
public void setAuthorpost(int authorpost) {
this.authorpost = authorpost;
}
/**
* @return 搜索帖子的标题、内容还是两者都搜索
*/
public int getContent() {
return content;
}
/**
* 搜索帖子的标题、内容还是两者都搜索
* @param content 搜索选型
*/
public void setContent(int content) {
this.content = content;
}
/**
* @return 搜索关键字
*/
public String getKeyword() {
return keyword;
}
/**
* 设置搜索关键字
* @param keyword 搜索关键字
*/
public void setKeyword(String keyword) {
this.keyword = keyword.trim();
}
/**
* @return 搜索时间范围
*/
public int getPostdate() {
return postdate;
}
/**
* 设置搜索时间范围
* @param postdate 搜索时间范围
*/
public void setPostdate(int postdate) {
this.postdate = postdate;
}
/**
* @return 搜索论坛Id
*/
public int getSchfmId() {
return schfmId;
}
/**
* 设置搜索论坛Id
* @param schfmId 搜索论坛Id
*/
public void setSchfmId(int schfmId) {
this.schfmId = schfmId;
}
public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest request) {
if(keyword==null || keyword.length()<1){
ActionErrors errors = new ActionErrors();
HttpSession session = request.getSession(true);
keyword = (String) session.getAttribute("keyword");
if(keyword==null || keyword.length()<1)
errors.add("article.search.keyword.empty",new ActionMessage("article.search.keyword.empty"));
return errors;
}
return null;
}
public void reset(ActionMapping actionMapping, HttpServletRequest request){
keyword = "";
authorpost = 0;
author = 0;
content = 0;
postdate = 0;
schfmId = 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -