String url = /cwhy.jsp;
……
else{ // 权限到期或没有开通
System.out.println("权限没有开通");
request.setAttribute("read_error", "<font color = red>对不起,您没有开通该产品或权限已过期!</font>");
forward.setPath(url);
但是却转发到index.jsp上去了。
求各位高手帮忙。
……
else{ // 权限到期或没有开通
System.out.println("权限没有开通");
request.setAttribute("read_error", "<font color = red>对不起,您没有开通该产品或权限已过期!</font>");
forward.setPath(url);
但是却转发到index.jsp上去了。
求各位高手帮忙。
解决方案 »
- struts2 表单xml验证失败后其他界面手工也进入不了?
- 不用STOP()方法怎么强制并且较安全的退出僵死的JAVA线程?请大虾们帮帮忙!
- servlet以及jsp资源在服务器中的执行流程?
- Struts的表格分页!
- 一个国际化的问题,请大家给看一下.谢谢.
- 高手讲讲session&cookie的区别和用法
- jdom处理xml文件的问题
- 谁用过Sun Java Studio Creator中文版
- 关于JDBC数据库连接的问题
- 关于ognl中s:checkboxList的几个疑问??
- 谁能给我一个增加用的超文本域!在线等,急。。
- Cannot instantiate the type Interceptor
String url = "/cwhy.jsp";
导致这样的原因有很多种
web.xml 没做任何配置 是会直接到这个页面的
还有可能是你的struts.xml 配置文件配置好了跳转到此页面
LZ 你先把的配置问题都贴出来吧
<action
attribute="selectBrowseForm"
name="selectBrowseForm"
path="/selectBrowse"
scope="request"
type="com.hexun.product.web.action.SelectBrowseAction"
validate="false" />
String url = "/cwhy.jsp";
forward.setPath(url); 然后, return forward;
但是还是跳转到 index.jsp
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener> <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/actionContext.xml,/WEB-INF/applicationContext.xml,/WEB-INF/daoContext.xml</param-value>
</context-param>
<!-- spring配置结束 --> <servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>dwr-invoker</servlet-name><!-- 指定处理DWR请求的Servlet名 -->
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class><!-- 指定处理DWR请求的Servlet类名 -->
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>scriptCompressed</param-name><!-- 简单的压缩 -->
<param-value>false</param-value><!-- 关闭或不压缩 -->
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- web.xml中配置DWR 结束! --><!-- 配置DWR在客户端的访问路径 -->
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<!--Struts标签库配置-->
<jsp-config>
<taglib>
<taglib-uri>/WEB-INF/tld/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tld/struts-html</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tld/struts-logic</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tld/struts-tiles</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-tiles.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tld/struts-nested</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-nested.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tld/spring</taglib-uri>
<taglib-location>/WEB-INF/tld/spring.tld</taglib-location>
</taglib>
</jsp-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!--中文编码过滤器-->
<filter>
<filter-name>EncodingFilter</filter-name>
<filter-class>com.hexun.framework.filter.EncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>ignore</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<servlet-name>/*</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
</web-app>***********************************
<action
attribute="browseForm"
input="/duoxuan.jsp"
name="browseForm"
path="/browse"
scope="request"
type="com.hexun.product.web.action.BrowseAction"
validate="false">
</action>
import java.util.*;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;import com.hexun.admin.service.IPermissionInfoService;
import com.hexun.framework.tools.date.DateUtil;
import com.hexun.framework.tools.date.TimeUtil;
import com.hexun.framework.tools.string.StringUtils;
import com.hexun.model.Permission;
import com.hexun.model.Product;
import com.hexun.product.service.IProductInfoService;
import com.hexun.product.web.form.SelectBrowseForm;public class SelectBrowseAction extends Action { private IPermissionInfoService permissionInfoService;
private IProductInfoService productInfoService;
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
SelectBrowseForm selectBrowseForm = (SelectBrowseForm) form;
ActionForward forward = new ActionForward();
HttpSession session = request.getSession();
List permissionList = new ArrayList();
DateUtil dateUtil = new DateUtil();
StringUtils stringUtil = new StringUtils();
TimeUtil timeUtil = new TimeUtil();
String reportDate = selectBrowseForm.getReportDate().trim();
if(reportDate==""||reportDate==null||reportDate.length()<1){
reportDate = timeUtil.getString(3);// 得到yyyy-MM-dd格式的String的当前时间
}
String reportDate2 = stringUtil.stringDashDateDToDateString(reportDate);//转化为没有“-”的时间格式字符串
String productNo = selectBrowseForm.getProductNo();
String areas = selectBrowseForm.getAreas();
String url = selectBrowseForm.getUrl();
String userId = (String) session.getAttribute("jgtz_userId");
String jgtz_Passage = "Dr7kY.35*w%6Z9;iq?>]c89I3$csdl09087{{{-9H7?2/s3*-|1rtv~z&.v`i{]%#!cs4892D+<@sdc456sdfcv*,.``za4fsH^#jx)";
//判断用户登录。
if(session.getAttribute("jgtz_Passage")==null||!session.getAttribute("jgtz_Passage").equals(jgtz_Passage)){
System.out.println("判断登录");
request.setAttribute("jgtz_errers", "<font color = red>对不起,您没有登录!请登录后阅读。</font>");
forward.setPath(url);
}
else{
//验证权限
permissionList = permissionInfoService.getPermissionByUserid(userId);
boolean stutas = false;
for(int i=0;i<permissionList.size();i++){
Permission permission = (Permission) permissionList.get(i);
if(permission.getAreas().equals(areas) && dateUtil.isSqldateAfterCur(permission.getEndTime())==true){
stutas = true;
break;
}
else{
continue;
}
}
if(stutas){//权限已 开通。
//验证文件是否存在
Product product = productInfoService.getProductByAreas(areas);
String areasAdd = (String)product.getLink();
//String areasAdd = ""; //browse.do为""
StringBuffer fileAdd = new StringBuffer();
fileAdd.append("/article/");
fileAdd.append(reportDate2);
fileAdd.append(areasAdd);
fileAdd.append("/");
fileAdd.append(productNo);
fileAdd.append(".html");
String fileAdd1 = fileAdd.toString();
System.out.println(request.getContextPath());
System.out.println(fileAdd1);
System.out.println(url);
// "\\"与"/"都可以,都表示"\"。因为在java中"\"是特殊符号,所以用以上两种方法来代替。
File file = new File("D:\\workspace\\investor\\WebRoot",fileAdd1);
if(file.exists()==true){
System.out.println("验证文件存在!");
forward.setPath(fileAdd1);
}
else{
System.out.println("验证文件不存在!");
request.setAttribute("read_error", "<font color = red>对不起,您查找的文件不存在,请重新输入!</font>");
forward.setPath(url);
}
}
else{ // 权限到期或没有开通
System.out.println("权限没有开通");
request.setAttribute("read_error", "<font color = red>对不起,您没有开通该产品或者权限已过期!</font>");
forward.setPath(url);
}
}
return forward;
}
public IPermissionInfoService getPermissionInfoService() {
return permissionInfoService;
}
public void setPermissionInfoService(
IPermissionInfoService permissionInfoService) {
this.permissionInfoService = permissionInfoService;
}
public IProductInfoService getProductInfoService() {
return productInfoService;
}
public void setProductInfoService(IProductInfoService productInfoService) {
this.productInfoService = productInfoService;
}}
/investor
/article/20100725/cwhy/000001.html
/cwhy.jsp
验证文件存在!
我清理了Tomcat中的文件过,重新发布过,重起机过。都不行。
而且我的另个一个Action用的这个方法是可以的。
所以我简单的说是 /cwhy.jsp, 但是问题都是一样的。
再次感谢大家的热心帮助。
我的问题解决了,是我的href="" 应该设置为"#"