我在项目中的web.xml中配制
<welcome-file-list>
<welcome-file>productshow.action?type=index</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
打算每次最初开始在浏览器中输入 http://localhost:8088/mshop/时,让页面跳转到productshow.action?type=index的action,但是第一次是进去了,如果第一次后再输入http://localhost:8088/mshop/却一直只跳转到index.jsp页面,也就是加载不上应该有的数据,所以就想使用拦截器,每次输入http://localhost:8088/mshop/时,都让其跳转到带有productshow.action?type=index所处理后的数据的页面,请问这样一个拦截器应该怎么写呢?谢谢,ip地址最好不固定
<welcome-file-list>
<welcome-file>productshow.action?type=index</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
打算每次最初开始在浏览器中输入 http://localhost:8088/mshop/时,让页面跳转到productshow.action?type=index的action,但是第一次是进去了,如果第一次后再输入http://localhost:8088/mshop/却一直只跳转到index.jsp页面,也就是加载不上应该有的数据,所以就想使用拦截器,每次输入http://localhost:8088/mshop/时,都让其跳转到带有productshow.action?type=index所处理后的数据的页面,请问这样一个拦截器应该怎么写呢?谢谢,ip地址最好不固定
解决方案 »
- 关于SSH开发中JSP页面向Action传值的问题!急~
- jsp问题
- hibernate保存oracle数据库里获取序列问题
- URL rewrite 技术问题?
- jdk1.4编译的配置
- java 中如何解释HTML?
- <jsp:useBean id="currentpage" scope="request" class="java.lang.Integer"/> 能这样用吗??
- 本人做个考试系统,客户要求题目即能编辑文本,还要以编辑公式,马上交工了,还没有找到命适的编辑器,大侠们 救救我。
- 2011-03-18 17:24:44,687 ERROR [com.garage.xsystem.EncryptService] - 字符串解密出现异常
- 请问为什麽在J2ee中客户端(测试时)用jndi定位enterprise bean的时候,可以把远程接口实例化?接口不是不可以生成对象的吗?
- 高分求助Java项目内存溢出问题
- struts2action里ActionContext.getContext().getSession()为空异常
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
index.jsp直接跳转到你的action
package org.liky.filter;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.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;public class InitFilter implements Filter { public void destroy() { } public void doFilter(ServletRequest req, ServletResponse resp,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
// System.out.println("request.getRemoteAddr()="+request.getRemoteAddr());
if (request.getSession().getServletContext()
.getAttribute("initcatalog") == null) {
if (request.getRequestURI().indexOf("login") == -1 && request.getRequestURI().indexOf("login") == -1) {
((HttpServletResponse)resp).sendRedirect("/mshop/productshow.action?type=index");
System.out.println("-----到了if语句---"+request.getRemoteAddr());
}
}
else{
String StrUrl="http://"+request.getRemoteAddr()+":8088/mshop";
String StrUrl2="http://localhost:8088/mshop";
if(StrUrl.equals(request.getRequestURI()) || StrUrl2.equals(request.getRequestURI())){
((HttpServletResponse)resp).sendRedirect("/mshop/productshow.action?type=index");
System.out.println("应该跳转request.getRequestURI().equals(strURL)=");
}
}
chain.doFilter(req, resp);
} public void init(FilterConfig arg0) throws ServletException {
}}
((HttpServletResponse)resp).sendRedirect("/mshop/productshow.action?type=index");
System.out.println("应该跳转request.getRequestURI().equals(strURL)=");
}
chain.doFilter(req, resp);
} public void init(FilterConfig arg0) throws ServletException {
}}当tomcat启动后,第一个进入action,后来再输入http://localhost:8088/shop/还是只是进入index.jsp页面,请指点!!谢谢