社区
Web 开发
帖子详情
请问如何只让在浏览器地栏输入http://local:8080/test/login_init.do有效,而屏蔽系统中其他的....x.do
jiebao
2003-08-19 01:30:23
请问如何只让在浏览器地栏输入http://local:8080/test/login_init.do有效,而屏蔽系统中其他的....x.do
...全文
223
12
打赏
收藏
请问如何只让在浏览器地栏输入http://local:8080/test/login_init.do有效,而屏蔽系统中其他的....x.do
请问如何只让在浏览器地栏输入http://local:8080/test/login_init.do有效,而屏蔽系统中其他的....x.do
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
12 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
jiebao
2003-08-20
打赏
举报
回复
按照上面的方法屏蔽不了.请指点
pcdll
2003-08-20
打赏
举报
回复
把httpResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);改成:
response.sendRedirect("login_init.do")即可
jiebao
2003-08-20
打赏
举报
回复
httpResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);//返回状态码404,未找到请求对象
我不想返回状态码404,未找到请求对象
, 想让它返回到程序的入口(login_init.do).可以吗?
jiebao
2003-08-20
打赏
举报
回复
test是我的一个应用程序根目录,我发现用以上的方法把所以.do都屏蔽了.是何原因
jiebao
2003-08-20
打赏
举报
回复
这样处理,只有login_init.do可以,其它的不行,但正系统正常进入时,其它的也打不开.请指点.
在线等.
谢谢
whodsow
2003-08-20
打赏
举报
回复
不应该这么配置的,应该是:
<filter>
<filter-name>URLFilter</filter-name>
<description>only /login_init.do</description>
<filter-class>filters.URLFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>URLFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
whodsow
2003-08-20
打赏
举报
回复
既然test是应用程序,改正如下:
package filters;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;
public class URLFilter implements Filter
{
private FilterConfig config;
protected final static String ALLOW_URI = "/login_init.do";
public void init(FilterConfig config)
{
this.config = config;
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)throws IOException,ServletException
{
HttpServletRequest httpRequest = (HttpServletRequest)request;
HttpServletResponse httpResponse = (HttpServletResponse)response;
String uri = httpRequest.getServletPath();
if(uri.endsWith(".do"))
{
if(uri.equals(ALLOW_URI))
{
chain.doFilter(request, httpResponse);
return;
}
config.getServletContext().getNamedDispatcher("login_init.do").forward(request, response);////login_init.do为<servlet-name>
}
chain.doFilter(request, httpResponse);
}
public void destroy()
{
}
}
在web.xml中再加入如下配置:
<filter>
<filter-name>URLFilter</filter-name>
<description>only /test/login_init.do</description>
<filter-class>filters.URLFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>URLFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
whodsow
2003-08-19
打赏
举报
回复
如下是过滤器类:
package filters;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;
public class URLFilter implements Filter
{
private FilterConfig config;
protected final static String ALLOW_URI = "/test/login_init.do";
public void init(FilterConfig config)
{
this.config = config;
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)throws IOException,ServletException
{
HttpServletRequest httpRequest = (HttpServletRequest)request;
HttpServletResponse httpResponse = (HttpServletResponse)response;
String uri = httpRequest.getServletPath();
if(uri.endsWith(".do"))
{
if(uri.equals(ALLOW_URI))
{
chain.doFilter(request, httpResponse);
return;
}
httpResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);//返回状态码404,未找到请求对象
}
chain.doFilter(request, httpResponse);
}
public void destroy()
{
}
}
在web.xml中再加入如下配置:
<filter>
<filter-name>URLFilter</filter-name>
<description>only /test/login_init.do</description>
<filter-class>filters.URLFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>URLFilter</filter-name>
<url-pattern>/test/*</url-pattern>
</filter-mapping>
whodsow
2003-08-19
打赏
举报
回复
test是你的一个应用程序,还是一个应用程序中的子文件夹呀??
jiebao
2003-08-19
打赏
举报
回复
急用,请知道的同志告诉我.谢谢
jiebao
2003-08-19
打赏
举报
回复
没有用过"过滤器",请说明如何用"过滤器"?谢谢
whodsow
2003-08-19
打赏
举报
回复
用过滤器啊,很简单的嘛
iframe 内嵌报跨域SecurityError: Blocked a frame with origin “
http
://x“from accessing a cross-origin frame
Vue 项目
中
嵌入 iframe <iframe id="iframe" width="100%" height="100%" frameborder="0" :src="embedSrc"></iframe> 报跨域错误 Error in nextTick: "SecurityError: Blocked a frame with origin ...
重新安装opencv,踩坑。
../../lib/libopencv_ts.a(ts_g
test
.cpp.o): In function `
test
ing::internal::RE::~RE()': ts_g
test
.cpp:(.text._ZN7
test
ing8internal2RED2Ev+0xf): undefined reference to `regfreeA' ts_g
test
.cpp:(.text._ZN7...
http
s://app.hackthebox.com/machines/Soccer
protocol 2.0) | ssh-hostkey: | 3072 ad0d84a3fdcc98a478fef94915dae16d (RSA) | 256 dfd6a39f68269dfc7c6a0c29e961f00c (ECDSA) |_ 256 5797565def793c2fcbdb35fff17c615c (ED25519) 80/tcp open
http
nginx ...
Google搜索关键字
\”inurl:\”Umbraco/#/
login
\” site:*edu\” \”site:ghostbin.com \” / \” \” \”site:hastebin.com \” / \” \” intitle:’index of’ \”error_log\” intitle:’index of’ \”access_log\” inurl:...
/etc/
init
.d/sshd配置SSHD路径忘记修改导致启动失败
[root@lnlte2dmr3 ~]# bash[root@lnlte2dmr3 ~]# install -v -m700 -d /var/empty/sshdinstall: 正在创建目录"/var/empty/sshd"[root@lnlte2dmr3 ~]# 等待
输入
超时:自动登出[root@lnlte2dmr3 ~]# bash[root@l...
Web 开发
81,091
社区成员
341,719
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章