当前位置: 代码迷 >> Java Web开发 >> 透过登录时获得的id,id和student表中的userid为外键关系,来查询登录时student表中对应用户的信息
  详细解决方案

透过登录时获得的id,id和student表中的userid为外键关系,来查询登录时student表中对应用户的信息

热度:44   发布时间:2016-04-16 22:00:56.0
通过登录时获得的id,id和student表中的userid为外键关系,来查询登录时student表中对应用户的信息。
通过登录时获得的id,id和student表中的userid为外键关系,来查询登录时student表中对应用户的信息。
jsp:
<tr><td><h4>欢迎   <%=user.getUserName()%>同学</h4></td></tr>
<td><a href="StudentAction!oneStudentDetails?userId=<s:property value="#enlist.id"/>">查看详情</a></td>

action:
 //查询单个学生信息
public String onestudentDetails() {
// ArticleVo.setTitle()
HttpServletRequest request = ServletActionContext.getRequest();
userId = (String) request.getParameter("userId");
studentVo= StudentDAO.StudentQueryForModify(userId);
return "oneStudentDetails";
}
报错:
2014-8-10 22:19:23 org.apache.struts2.dispatcher.Dispatcher warn
警告: Could not find action or result: /A/StudentAction!oneStudentDetails?userId=<s:property%20value=
There is no Action mapped for namespace [/] and action name [StudentAction!oneStudentDetails] associated with context path [/A]. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:552)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at csu.soft.boss.utils.MyStrusFilter.doFilter(MyStrusFilter.java:22)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
at java.lang.Thread.run(Thread.java:619)
------解决方案--------------------
引用:
Quote: 引用:

<a href="StudentAction!oneStudentDetails?userId=<s:property value="#enlist.id"/>"> 这种写法支持吗?
看错误信息,应该是这种写法不支持,想办法把enlist.id 拿出来,拼接在连接后面


怎么拼接啊,不是太明白


如果说你是把list存在域对象里面的,那么你可以使用:
<a href="StudentAction!oneStudentDetails?userId=${enlist.id}"/>"> 不要学了struts就忘记了jsp

如果不是的话,那么你就使用<s:set>标签先存起来吧,然后再按照上面的方式取就行了
  相关解决方案