action定义如下:
[code="java"]
public class CRMGuestAction extends DispatchAction {
private CRMDao crmDao;
public ActionForward save(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaValidatorForm f = (DynaValidatorForm) form;
JzGuestbook guestbook = new JzGuestbook();
guestbook.setCpcode(cpcode);
guestbook.setAddress(address);
guestbook.setContel(contel);
guestbook.setContect(contect);
guestbook.setTel(tel);
guestbook.setRegisternumber(registernumber);
List all = null;
int currentPage = 1;
int lineSize = 3;
int allRecorders = 0;
try {
currentPage = Integer.parseInt(request.getParameter("cp"));
} catch (Exception e) {
}
try {
crmDao.addGuestbook(guestbook);
allRecorders = crmDao.getGuestbookTotal();
all = crmDao.getAllGuestbook(currentPage, lineSize);
} catch (Exception e) {
e.printStackTrace();
}
request.setAttribute("currentPage", currentPage);
request.setAttribute("lineSize", lineSize);
request.setAttribute("allRecorders", allRecorders);
request.setAttribute("jspUrl", "cRMGuest.do");
request.setAttribute("all", all);
return mapping.findForward("indexguest");
}
public ActionForward selectall(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("here");
List all = null;
int currentPage = 1;
int lineSize = 3;
int allRecorders = 0;
try {
System.out.println(request.getParameter("cp"));
currentPage = Integer.parseInt(request.getParameter("cp"));
} catch (Exception e) {
e.printStackTrace();
}
try {
allRecorders = crmDao.getGuestbookTotal();
all = crmDao.getAllGuestbook(currentPage, lineSize);
} catch (Exception e) {
e.printStackTrace();
}
request.setAttribute("currentPage", currentPage);
request.setAttribute("lineSize", lineSize);
request.setAttribute("allRecorders", allRecorders);
request.setAttribute("jspUrl", "cRMGuest.do");
request.setAttribute("all", all);
return mapping.findForward("indexguest");
}
public void setCrmDao(CRMDao crmDao) {
this.crmDao = crmDao;
}
}
[/code]
这页是jsp页面如下:
[code="java"]
[color=red] onsubmit="return validateCRMGuestForm(this)">
客户名称:
/html:text
联系人:
/html:text
联系电话:
/html:text
地址:
/html:text
/html:form
<table border="0" width="100%">
<tr>
<td>
联系人
</td>
<td>
联系电话
</td>
</tr>
<c:forEach items="${requestScope['all']}" var="user">
<tr>
<td>
<c:out value="${user.contect}"></c:out>
</td>
<td>
<c:out value="${user.contel}"></c:out>
</td>
</tr>
</c:forEach>
</table>
<jsp:include page [color=red]="/split_page.jsp">[/color]
<jsp:param name="lineSize" value="${lineSize}" />
<jsp:param name="jspUrl" value="${jspUrl}" />
<jsp:param name="allRecorders" value="${allRecorders}" />
<jsp:param name="currentPage" value="${currentPage}" />
<jsp:param name="searchFlag" value="F" />
</jsp:include>
</body>
[/code]
split_page.jsp为:
[code="java"]
<%@ page contentType="text/html;charset=utf-8"%>
<%
String jspUrl = null ;
int lineSize = 10 ;
int currentPage = 1 ;
int pageSize = 0 ;
int allRecorders = 0;
String keyWord = null ;
String searchFlag = "F" ;
%>
<%
jspUrl = request.getParameter("jspUrl") ;
keyWord = request.getParameter("keyWord") ;
searchFlag = request.getParameter("searchFlag") ;
try
{
[color=red]lineSize = Integer.parseInt(request.getParameter("lineSize")) ;
currentPage = Integer.parseInt(request.getParameter("currentPage")) ;
allRecorders = Integer.parseInt(request.getParameter("allRecorders")) ;//会产生java.lang.NumberFormatException: For input string: "" [/color] }
catch(Exception e)
{
// }
%>
<% pageSize = (allRecorders+lineSize-1)/lineSize ;
%>
[color=red]
">/*产生url地址*/[/color]<%if("T".equals(searchFlag))
{
%>
输入查询关键字:">
<%
}
%>
<%
if(allRecorders>0)
{
%>
>
<%=currentPage%>
/
<%=pageSize%>
跳转到
<%
for(int x=1;x<=pageSize;x++)
{
%>
input="/crm/cRMGuest.jsp"
name="cRMGuestForm"
parameter="method"
path="/cRMGuest"
scope="request"
type="org.springframework.web.struts.DelegatingActionProxy" >
[/code]
现在是提交好信息时会列出第一页信息,点击下一页时,uri的地址:http://localhost:8088/Demo/cRMGuest.do?method=selectall&cp=2&selpage=1是正确的,但是第二页的信息却显示不出来,同时我在CRMGuestAction的seletall中标注了断点以及起始处写上输出标识,但是在点下一页时单步调试时并没有运行到那里就停止了,是我那个地方设置的不对?
[b]问题补充:[/b]
action定义如下:
[code="java"]
public class CRMGuestAction extends DispatchAction {
private CRMDao crmDao;
public ActionForward save(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaValidatorForm f = (DynaValidatorForm) form;
JzGuestbook guestbook = new JzGuestbook();
guestbook.setCpcode(cpcode);
guestbook.setAddress(address);
guestbook.setContel(contel);
guestbook.setContect(contect);
guestbook.setTel(tel);
guestbook.setRegisternumber(registernumber);
List all = null;
int currentPage = 1;
int lineSize = 3;
int allRecorders = 0;
try {
currentPage = Integer.parseInt(request.getParameter("cp"));
} catch (Exception e) {
}
try {
crmDao.addGuestbook(guestbook);
allRecorders = crmDao.getGuestbookTotal();
all = crmDao.getAllGuestbook(currentPage, lineSize);
} catch (Exception e) {
e.printStackTrace();
}
request.setAttribute("currentPage", currentPage);
request.setAttribute("lineSize", lineSize);
request.setAttribute("allRecorders", allRecorders);
request.setAttribute("jspUrl", "cRMGuest.do");
request.setAttribute("all", all);
return mapping.findForward("indexguest");
}
public ActionForward selectall(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("here");
List all = null;
int currentPage = 1;
int lineSize = 3;
int allRecorders = 0;
try {
System.out.println(request.getParameter("cp"));
currentPage = Integer.parseInt(request.getParameter("cp"));
} catch (Exception e) {
e.printStackTrace();
}
try {
allRecorders = crmDao.getGuestbookTotal();
all = crmDao.getAllGuestbook(currentPage, lineSize);
} catch (Exception e) {
e.printStackTrace();
}
request.setAttribute("currentPage", currentPage);
request.setAttribute("lineSize", lineSize);
request.setAttribute("allRecorders", allRecorders);
request.setAttribute("jspUrl", "cRMGuest.do");
request.setAttribute("all", all);
return mapping.findForward("indexguest");
}
public void setCrmDao(CRMDao crmDao) {
this.crmDao = crmDao;
}
}
[/code]
这页是jsp页面如下:
[code="java"]
[color=red] onsubmit="return validateCRMGuestForm(this)">
客户名称:
/html:text
联系人:
/html:text
联系电话:
/html:text
地址:
/html:text
/html:form
<table border="0" width="100%">
<tr>
<td>
联系人
</td>
<td>
联系电话
</td>
</tr>
<c:forEach items="${requestScope['all']}" var="user">
<tr>
<td>
<c:out value="${user.contect}"></c:out>
</td>
<td>
<c:out value="${user.contel}"></c:out>
</td>
</tr>
</c:forEach>
</table>
<jsp:include page [color=red]="/split_page.jsp">[/color]
<jsp:param name="lineSize" value="${lineSize}" />
<jsp:param name="jspUrl" value="${jspUrl}" />
<jsp:param name="allRecorders" value="${allRecorders}" />
<jsp:param name="currentPage" value="${currentPage}" />
<jsp:param name="searchFlag" value="F" />
</jsp:include>
</body>
[/code]
split_page.jsp为:
[code="java"]
<%@ page contentType="text/html;charset=utf-8"%>
<%
String jspUrl = null ;
int lineSize = 10 ;
int currentPage = 1 ;
int pageSize = 0 ;
int allRecorders = 0;
String keyWord = null ;
String searchFlag = "F" ;
%>
<%
jspUrl = request.getParameter("jspUrl") ;
keyWord = request.getParameter("keyWord") ;
searchFlag = request.getParameter("searchFlag") ;
try
{
[color=red]lineSize = Integer.parseInt(request.getParameter("lineSize")) ;
currentPage = Integer.parseInt(request.getParameter("currentPage")) ;
allRecorders = Integer.parseInt(request.getParameter("allRecorders")) ;//会产生java.lang.NumberFormatException: For input string: "" [/color] }
catch(Exception e)
{
// }
%>
<% pageSize = (allRecorders+lineSize-1)/lineSize ;
%>
[color=red]
">/*产生url地址*/[/color]<%if("T".equals(searchFlag))
{
%>
输入查询关键字:">
<%
}
%>
<%
if(allRecorders>0)
{
%>
>
<%=currentPage%>
/
<%=pageSize%>
跳转到
<%
for(int x=1;x<=pageSize;x++)
{
%>
input="/crm/cRMGuest.jsp"
name="cRMGuestForm"
parameter="method"
path="/cRMGuest"
scope="request"
type="org.springframework.web.struts.DelegatingActionProxy" >
[/code]
现在是提交好信息时会列出第一页信息,点击下一页时,uri的地址:http://localhost:8088/Demo/cRMGuest.do?method=selectall&cp=2&selpage=1是正确的,但是第二页的信息却显示不出来,同时我在CRMGuestAction的seletall中标注了断点以及起始处写上输出标识,但是在点下一页时单步调试时并没有运行到那里就停止了,是我那个地方设置的不对? [color=red]">[/color]这是生成的地址,地址没问题是正确的。
[b]问题补充:[/b]
查询关键字还没有涉及,这个应该不是这方面的问题。
[b]问题补充:[/b]
[color=red]这个问题的关键是生成的url是正确的,但是没有去跳转到action中,是不是配置的问题?我的工程目录如下:
web-root
--web-inf
--crm
--cRMGuest.jsp
--single-page.jsp[/color]
[b]问题补充:[/b]
[color=red]我按照您说的输入url:http://localhost:8088/Demo/cRMGuest.do?method=selectall&cp=2&selpage=1,没有显示,所以我觉得可能配置有问题,我能显示的第一个页面,因为我首先要提交一些信息后,我用的jsp中action的地址是/cRMGuest.do?method=save,然后再进入的时候,我把url换为url:http://localhost:8088/Demo/cRMGuest.do?method=selectall&cp=2&selpage=1就不保存那些提交的信息了。[/color]