The Struts dispatcher cannot be found. This is usually caused by using Struts t

阅读更多

严重: Servlet.service() for servlet jsp threw exception

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 org.apache.jsp.index_jsp._jspx_meth_s_005faction_005f0(index_jsp.java:128)

at org.apache.jsp.index_jsp._jspService(index_jsp.java:96)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

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:293)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)

at java.lang.Thread.run(Thread.java:619)

 

出现以上错误原因是:

页面上使用struts标签如:

<%@taglib uri="/struts-tags"  prefix="s"%>

  
  	
  

 

 解决如上在web.xml过滤struts过滤器的时候过滤action 同时也过滤jsp

  
  	struts2
  	
  		org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
  	
  
  
  	struts2
  	*.action
  
  
  	struts2
  	*.jsp
  

 

 后台代码:

public class CusAction{

	public String val;
	
	public void like(){
		//是以request方式的值的,而不是以参数传值 
		/*
		 * 用reqeust.getParameter 是无法 取到值得
		 *
		 */
		System.out.println("直接赋值"+val);
		System.out.println("request取值"+ServletActionContext.getRequest().getAttribute("val"));
		
	}
	
}
  • The Struts dispatcher cannot be found. This is usually caused by using Struts t_第1张图片
  • 大小: 424.5 KB
  • 查看图片附件

你可能感兴趣的:(struts,struts-tag)