ptl_main.jsp:
<c:if>标签判断表达式的值,如果表达式的值为 true 则执行其主体内容。
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<tr>
<td align="right">
按状态:
</td>
<td><!-- turnToProjectPage.action -->
<a onclick="statuscli(0)"
<c:if test="${count.status==''}">style="background-color:#F60"</c:if>>全部</a>
<a onclick="statuscli(1)" name="status" id="NonDesignPaper" value="1"
<c:if test="${count.status==1}">style="background-color:#F60"</c:if>>申请</a>
<a onclick="statuscli(2)" name="status" id="NonSurvey" value="2"
<c:if test="${count.status==2}">style="background-color:#F60"</c:if>>审核</a>
<a onclick="statuscli(3)" name="status" id="SurveyBegin" value="3"
<c:if test="${count.status==3}">style="background-color:#F60"</c:if>>创建</a>
<a onclick="statuscli(4)" name="status" id="SurveyPause" value="4"
<c:if test="${count.status==4}">style="background-color:#F60"</c:if>>测试</a>
<a onclick="statuscli(5)" name="status" id="SurveyEnd" value="5"
<c:if test="${count.status==5}">style="background-color:#F60"</c:if>>发布</a>
<input id="status" name="status" size="4" value="${count.status}" type="hidden"/>
</td>
</tr>
main.jsp:
<label class="ml10">按状态:</label>
<div class="btn-group">
<button type="button" class="btn btn-default btn-sm">
<i class="fa fa-flag-checkered"></i>
<c:if test="${count.status==''}">
<%=res.getString("main_all") %>
</c:if>
<c:if test="${count.status==1}">
<%=res.getString("main_notdesign_paper") %>
</c:if>
<c:if test="${count.status==2}">
<%=res.getString("main_notsurvey") %>
</c:if>
<c:if test="${count.status==3}">
<%=res.getString("main_surveying") %>
</c:if>
<c:if test="${count.status==4}">
<%=res.getString("main_pause_survey") %>
</c:if>
<c:if test="${count.status==5}">
<%=res.getString("main_surveyend") %>
</c:if>
</button>
<button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li>
<a onclick="statuscli(1)" name="status" id="NonDesignPaper" value="1" <c:if test="${count.status==1}">class="active"</c:if
<%=res.getString("main_notdesign_paper") %>
</a>
</li>
<li>
<a onclick="statuscli(2)" name="status" id="NonSurvey" value="2" <c:if test="${count.status==2}">class="active"</c:if>>
<%=res.getString("main_notsurvey") %>
</a>
</li>
<li>
<a onclick="statuscli(3)" name="status" id="SurveyBegin" value="3" <c:if test="${count.status==3}">class="active"</c:if>>
<%=res.getString("main_surveying") %>
</a>
</li>
<li>
<a onclick="statuscli(4)" name="status" id="SurveyPause" value="4" <c:if test="${count.status==4}">class="active"</c:if>>
<%=res.getString("main_pause_survey") %>
</a>
</li>
<li>
<a onclick="statuscli(5)" name="status" id="SurveyEnd" value="5" <c:if test="${count.status==5}">class="active"</c:if>>
<%=res.getString("main_surveyend") %>
</a>
</li>
<li class="divider"></li>
<li>
<a onclick="statuscli(0)"
<c:if test="${count.status==''}">class="active"</c:if>>
<%=res.getString("main_all") %>
</a>
</li>
</ul>
<input id="status" name="status" size="4" value="${count.status}" type="hidden"/>
</div>
<div style="display:none">
action.java:
public String queryPro() {
HttpServletRequest request = ServletActionContext.getRequest();
// 模糊查询
SearchConditionDto sDto = (SearchConditionDto) MemcacheUtil.getMemcached("sdto");
name = request.getParameter("pr_Name");
ProjectDto dto = new ProjectDto();
dto.setPr_Name(name);
if (sDto != null) {
dto.setU_Id(sDto.getUid());
}
prolist = this.projectService.queryProject(dto);
if (prolist != null) {
// projectDto添加 状态的名称
for (int i = 0; i < prolist.size(); i++) {
// 查询状态表
ProjectStateDto psDto = new ProjectStateDto();
psDto.setPs_ID(prolist.get(i).getpS_Id());
List<ProjectStateDto> pDtos = this.projectstateService.queryProjectState(psDto);
// 项目表增加状态名称
for (ProjectStateDto projectstateDto : pDtos) {
if (projectstateDto.getPs_Name().equals("NonDesignPaper")) {
prolist.get(i).setStatus("未设计问卷");
} else if (projectstateDto.getPs_Name().equals("NonSurvey")) {
prolist.get(i).setStatus("未调查");
} else if (projectstateDto.getPs_Name().equals("SurveyBegin")) {
prolist.get(i).setStatus("调查中");
} else if (projectstateDto.getPs_Name().equals("SurveyPause")) {
prolist.get(i).setStatus("调查暂停");
} else if (projectstateDto.getPs_Name().equals("SurveyEnd")) {
prolist.get(i).setStatus("调查结束");
}
}
}
}
// 模糊查询分页
if (sDto != null) {
log.error(sDto.getUserName() + "按条件project.pr_Name=" + name + "进行了模糊查询");
}
return SUCCESS;
}
servlet.java:
/*
* 模糊查询
*/
public ModelAndView queryPro(HttpServletRequest request,
HttpServletResponse response) {
// 模糊查询
SearchConditionDto sDto = (SearchConditionDto) MemcacheUtil
.getMemcached("sdto",request);
String name = request.getParameter("pr_Name");
ProjectDto dto = new ProjectDto();
dto.setPr_Name(name);
if (sDto != null) {
dto.setU_Id(sDto.getUid());
}
List<ProjectDto> list = this.projectService.queryProject(dto);
if (list != null) {
// projectDto添加 状态的名称
for (int i = 0; i < list.size(); i++) {
// 查询状态表
ProjectStateDto psDto = new ProjectStateDto();
psDto.setPs_ID(list.get(i).getpS_Id());
List<ProjectStateDto> pDtos = this.projectstateService
.queryProjectState(psDto);
// 项目表增加状态名称
for (ProjectStateDto projectstateDto : pDtos) {
if (projectstateDto.getPs_Name().equalsIgnoreCase("NonDesignPaper")) {
list.get(i).setStatus("未设计问卷");
} else if (projectstateDto.getPs_Name().equalsIgnoreCase("NonSurvey")) {
list.get(i).setStatus("未调查");
} else if (projectstateDto.getPs_Name().equalsIgnoreCase(
"SurveyBegin")) {
list.get(i).setStatus("调查中");
} else if (projectstateDto.getPs_Name().equalsIgnoreCase(
"SurveyPause")) {
list.get(i).setStatus("调查暂停");
} else if (projectstateDto.getPs_Name().equalsIgnoreCase("SurveyEnd")) {
list.get(i).setStatus("调查结束");
}
}
}
}
// 模糊查询分页
if (sDto != null) {
log.error(sDto.getUserName() + "按条件project.pr_Name=" + name
+ "进行了模糊查询");
}
ModelAndView mav = new ModelAndView("main.jsp");
mav.addObject("prolist", list);
mav.addObject("name", name);
return mav;
}
网友评论