Struts2.0页面跳转css无效问题的解决方法
2012-05-22 15:39
633 查看
今天遇到一个问题,在通过action跳转的时候,由于是跳转到包外的一个文件,结果css就失效了。上网查了一下,主要还是路径的问题。最简单的解决方法就是利用重定向就OK了。
<result name="success" type="redirect"></result>
顺便查了一下struts2支持的一些结果类型,一并列在下面:
type支持的结果类型:
chain:用来处理Action链
chart:整合JFreeChart的结果类型
dispatcher:用来转向页面,通常处理JSP
freemaker:处理FreeMarker模板
httpheader:控制特殊HTTP行为的结果类型
jasper:用于JasperReports整合的结果类型
jsf:JSF整合的结果类型
redirect:重定向到一个URL
redirect-action:重定向到一个Action
stream:向浏览器发送InputSream对象,通常用来处理文件下载,还可用于返回AJAX数据
tiles:与Tiles整合的结果类型
velocity:处理Velocity模板
xslt:处理XML/XLST模板
plaintext:显示原始文件内容,例如文件源代码
转载自:http://blog.csdn.net/cxc3980/article/details/3973324
----------------------------------------------------------------------------------------------------------------------------------
另一种方法:
像页面转跳失效问题肯定是路径的问题。建议改相对路径为绝对路径。
Java代码
![](http://andy136566.iteye.com/images/icon_copy.gif)
String path = request.getContextPath();
String basePase = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
Java代码
![](http://andy136566.iteye.com/images/icon_copy.gif)
![](http://andy136566.iteye.com/images/icon_star.png)
![](http://andy136566.iteye.com/images/spinner.gif)
<SPAN style="FONT-SIZE: medium">String path = request.getContextPath();
String basePase = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";</SPAN>
引用css:
Html代码
![](http://andy136566.iteye.com/images/icon_copy.gif)
<link
rel="stylesheet"
type="text/css"
href="<%=basePath%>main.css">
Html代码
![](http://andy136566.iteye.com/images/icon_copy.gif)
![](http://andy136566.iteye.com/images/icon_star.png)
![](http://andy136566.iteye.com/images/spinner.gif)
<SPAN
style="FONT-SIZE: medium"><link
rel="stylesheet"
type="text/css"
href="<%=basePath%>main.css"></SPAN>
<result name="success" type="redirect"></result>
顺便查了一下struts2支持的一些结果类型,一并列在下面:
type支持的结果类型:
chain:用来处理Action链
chart:整合JFreeChart的结果类型
dispatcher:用来转向页面,通常处理JSP
freemaker:处理FreeMarker模板
httpheader:控制特殊HTTP行为的结果类型
jasper:用于JasperReports整合的结果类型
jsf:JSF整合的结果类型
redirect:重定向到一个URL
redirect-action:重定向到一个Action
stream:向浏览器发送InputSream对象,通常用来处理文件下载,还可用于返回AJAX数据
tiles:与Tiles整合的结果类型
velocity:处理Velocity模板
xslt:处理XML/XLST模板
plaintext:显示原始文件内容,例如文件源代码
转载自:http://blog.csdn.net/cxc3980/article/details/3973324
----------------------------------------------------------------------------------------------------------------------------------
另一种方法:
像页面转跳失效问题肯定是路径的问题。建议改相对路径为绝对路径。
Java代码
![](http://andy136566.iteye.com/images/icon_copy.gif)
String path = request.getContextPath();
String basePase = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
Java代码
![](http://andy136566.iteye.com/images/icon_copy.gif)
![](http://andy136566.iteye.com/images/icon_star.png)
![](http://andy136566.iteye.com/images/spinner.gif)
<SPAN style="FONT-SIZE: medium">String path = request.getContextPath();
String basePase = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";</SPAN>
String path = request.getContextPath(); String basePase = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
引用css:
Html代码
![](http://andy136566.iteye.com/images/icon_copy.gif)
<link
rel="stylesheet"
type="text/css"
href="<%=basePath%>main.css">
Html代码
![](http://andy136566.iteye.com/images/icon_copy.gif)
![](http://andy136566.iteye.com/images/icon_star.png)
![](http://andy136566.iteye.com/images/spinner.gif)
<SPAN
style="FONT-SIZE: medium"><link
rel="stylesheet"
type="text/css"
href="<%=basePath%>main.css"></SPAN>
相关文章推荐
- Struts2.0页面跳转css无效问题的解决方法
- Struts2.0页面跳转css无效问题的解…
- struts中Action跳转jsp页面图片.css乱----解决方法
- bootstrap模态框跳转到当前模板页面 框消失了而背景存在问题的解决方法
- 转:【WebDriver】封装GET方法来解决页面跳转不稳定的问题
- Servlet 使用getRequestDispatcher进行请求转发页面未跳转 后台也未报错的问题的解决方法
- 微信小程序出现wx.navigateTo页面不跳转问题的解决方法
- WebDriver封装GET方法来解决页面跳转不稳定的问题
- asp.NET 2.0中引发CSS失效问题原因和解决方法
- 解决href使用onclick方法时点击该链接的时候不会跳转页面.但是滚动条会往上滚的问题
- 页面跳转后查询状态保存问题的解决(较为笨拙的方法)
- CSS解决页面图片水平垂直居中问题的方法
- php页面跳转session cookie丢失,不能登录等问题解决方法
- Asp.net页面中引用js文件无效的问题的解决方法
- js不能跳转到上一页面的问题解决方法
- Asp.net页面中引用js文件无效的问题的解决方法
- Liferay中actionURL能够执行后台方法 ,但是页面不跳转问题解决方案
- jQuery Mobile页面跳转导致css、js失效原因及解决方法
- Struts1.2+Spring2.0+Hibernate3.1项目框架构建中的问题及解决方法集锦
- php页面跳转session cookie丢失导致不能登录等问题的解决方法