NutzCN Logo
问答 sitemesh3+nutz WEB-INF下的路径无法过滤
发布于 2627天前 作者 悍匪 2039 次浏览 复制 上一个帖子 下一个帖子
标签:
<?xml version="1.0" encoding="UTF-8"?>

<sitemesh>  
   <mapping  decorator="/WEB-INF/sitemesh/sitemesh.jsp"/> 
  <mapping path="/WEB-INF/mobile/goodsList.jsp" exclude="true"/>  
  <mapping path="/login.jsp" exclude="true"/>  
  
</sitemesh>  

可以过滤login.jsp
但是只要是过滤web-inf下的文件都不行

9 回复

跟入口方法有关系吗?

应该是没关系的
因为第一个入口就是sitemesh

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
	id="nutzbook" version="3.0">
	<filter>
		<filter-name>sitemesh</filter-name>
		<filter-class>org.sitemesh.config.ConfigurableSiteMeshFilter</filter-class>
		
	</filter>
	<filter-mapping>
		<filter-name>sitemesh</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<filter>
		<filter-name>Wx_jewel</filter-name>
		<filter-class>com.subang.jewel.shiro.realm.ResourceFilter</filter-class>
		<init-param>
			<param-name>modules</param-name>
			<param-value>com.subang.jewel.MainModule</param-value>
		</init-param>
	</filter>

	<filter-mapping>
		<filter-name>Wx_jewel</filter-name>
		<url-pattern>/*</url-pattern>
		<dispatcher>REQUEST</dispatcher>
		<dispatcher>FORWARD</dispatcher>
		<dispatcher>INCLUDE</dispatcher>
		<dispatcher>ERROR</dispatcher>
	</filter-mapping>


	<filter>
		<filter-name>nutz</filter-name>
		<filter-class>org.nutz.mvc.NutFilter</filter-class>
		<init-param>
			<param-name>modules</param-name>
			<param-value>com.subang.jewel.MainModule</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>nutz</filter-name>
		<url-pattern>/*</url-pattern>
		<dispatcher>REQUEST</dispatcher>
		<dispatcher>FORWARD</dispatcher>
		<dispatcher>INCLUDE</dispatcher>
	</filter-mapping>
	<welcome-file-list>
		<welcome-file>login.jsp</welcome-file>
	</welcome-file-list>
</web-app>

测试一下,经过入口方法和不经过入口方法的两个jsp,看看是否都能工作

还真是 不经过入口方法的可以过滤 经过的就不行了 好像是入口方法的事情

这样写试试

@Ok("jsp:xxxxx")
public void xxxx(){
     Mvcs.getActionContext().set(ActionContext.AC_DONE, false);
}


@At("/sales") @Ok("jsp:/mobile/goodsList") public void goods(){ Mvcs.getActionContext().set(ActionContext.AC_DONE, false);
九月 06, 2017 6:20:48 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [default] in context with path [/Wx_jewel] threw exception
java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
	at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:450)
	at javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:119)
	at org.sitemesh.webapp.contentfilter.HttpServletResponseBuffer.sendError(HttpServletResponseBuffer.java:261)
	at org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:841)
	at org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:441)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.nutz.mvc.NutFilter.nextChain(NutFilter.java:226)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:201)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at com.subang.jewel.shiro.realm.ResourceFilter.doFilter(ResourceFilter.java:40)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.sitemesh.webapp.contentfilter.ContentBufferingFilter.bufferAndPostProcess(ContentBufferingFilter.java:169)
	at org.sitemesh.webapp.contentfilter.ContentBufferingFilter.doFilter(ContentBufferingFilter.java:126)
	at org.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:120)
	at org.sitemesh.config.ConfigurableSiteMeshFilter.doFilter(ConfigurableSiteMeshFilter.java:163)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1083)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)

发现了个问题 为什么@Ok("jsp:/xxxx") 直接报404 url文件路径是对的

看来不行

项目代码机密不?要不把你的项目上传到github或者码云,然后我clone下来测试一下

就是代码有点恶心 哈哈

添加回复
请先登陆
回到顶部