从普通jsp页面调用struts2 jsp页面
我有一个现有的普通jsp web应用程序。 根据客户要求,我需要创建一些带有下拉选择框的配置页面。我必须在Struts 2中创建这个页面。 我已经创建了一个struts页面,但无法从现有的应用程序调用这个struts2页面 我正在犯错误从普通jsp页面调用struts2 jsp页面,jsp,struts2,struts,Jsp,Struts2,Struts,我有一个现有的普通jsp web应用程序。 根据客户要求,我需要创建一些带有下拉选择框的配置页面。我必须在Struts 2中创建这个页面。 我已经创建了一个struts页面,但无法从现有的应用程序调用这个struts2页面 我正在犯错误 The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are
The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
at org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
at org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44)
at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)
at jsp_servlet.__addprevdn._jsp__tag0(__addprevdn.java:112)
at jsp_servlet.__addprevdn._jspService(__addprevdn.java:84)
Truncated. see log file for complete stacktrace
正如Umesh Awasthi所说,你不能那样做。你需要了解Struts2的一些基础知识
- 首先,客户机请求通过Servlet容器,如Tomcat。然后,客户机请求通过一个链接系统,该系统涉及Servlet过滤器的三个组件
- 在链接系统中,首先是
通过HttpServletrequest
过滤器。ActionContextCleanUp
与ActionContextCleanUp
或一起工作,并允许与FilterDispatcher
集成SiteMesh
- 接下来,
调用FilterDispatcher
,以确定哪个请求应该调用操作。它还处理执行操作,清理ActionMapper
,并在Struts2的各个部分需要时提供静态内容,如JavaScript文件、CSS文件、HTML文件等ActionContext
映射HTTP请求和操作调用请求,反之亦然。ActionMapper
可能会返回一个动作,如果没有动作调用请求匹配,则可能会返回null值ActionMapper
- 当
希望调用某个操作时,通过与ActionMapper
交互来调用FilterDispatcher
。ActionProxy
获取Action类并调用适当的方法。此方法参考框架配置管理器,该管理器是从ActionProxy
文件初始化的struts.xml
- 读取
文件后,struts.xml
创建一个ActionProxy
&确定应该如何处理该操作ActionInvocation
封装了如何获取操作,&ActionProxy
封装了调用请求时如何执行操作ActionInvocation
- 然后,
在ActionProxy
的帮助下调用拦截器。拦截器的主要任务是使用ActionInvocation
调用操作ActionInvocation
- 一旦确定并执行了操作,则使用
组件生成结果。result
组件在Result
中映射的操作结果代码的帮助下从模板中查找数据该模板可能包含用于生成响应的JSP、FreeMarkerstruts.xml
FilterDispatcher
(org.apache.struts2.dispatcher.FilterDispatcher),自struts2.1.3以来,它已被弃用
如果您使用的是Struts版本>=2.1.3,则始终建议升级新的筛选器类–StrutsPrepareAndExecuteFilter
(org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter)
一些有用的链接
希望这有帮助。你不能这样做,如果你绕过Struts2过滤器,框架还没有准备好为你服务,也没有标记,这也是对MVC不利的。请弄清楚如何使用struts2