1:<img src="<s:property value='%{student.getSpath()}' />" width='240' height="240" />
其中:<s:property value='%{student.getSpath()}' />可能为空,我想让他为空的时候自动换成imageLoad/default.jpg这个路径。
2:接着第一问:当img显示时,如果我把这个图片给换成同名的不同图片,为什么都要在我手动刷新一下才能正常显示新的图片?
3:我用<result name="studentDeleteSuccess">/Student_listAll.action</result>转到同一个Action为什么会报错啊,过我改成<result name="studentDeleteSuccess">/deleteStudent_success.html</result>,也就是先转到html页面,再在html中转到Student_listAll.action又可以呢?
我的web.xml配置:
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
struts.xml:
<action name="Student_*" class="org.wjl.mgqs.action.StudentAction" method="{1}">
<result name="listAll">/listStudent.jsp</result>
<result name="studentDeleteSuccess">/Student_listAll.action</result>
</action>
其中:<s:property value='%{student.getSpath()}' />可能为空,我想让他为空的时候自动换成imageLoad/default.jpg这个路径。
2:接着第一问:当img显示时,如果我把这个图片给换成同名的不同图片,为什么都要在我手动刷新一下才能正常显示新的图片?
3:我用<result name="studentDeleteSuccess">/Student_listAll.action</result>转到同一个Action为什么会报错啊,过我改成<result name="studentDeleteSuccess">/deleteStudent_success.html</result>,也就是先转到html页面,再在html中转到Student_listAll.action又可以呢?
我的web.xml配置:
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
struts.xml:
<action name="Student_*" class="org.wjl.mgqs.action.StudentAction" method="{1}">
<result name="listAll">/listStudent.jsp</result>
<result name="studentDeleteSuccess">/Student_listAll.action</result>
</action>
解决方案 »
- 有人用过新浪微博oauth第3方授权么????????????????????????????
- 怎样在Spring中配置多个数据源
- 一个多条件查询的问题?
- 模块,子系统的疑惑
- 不知道如何解决了高手看下
- 如何将一个十六进制的数字字符CH转换成对应的整数类型值? 在线等~~
- 请教:在web应用中,怎样减少网络负载,有哪些方法?
- 大家好!请问哪儿能下到jubilder X自带的帮助文档!
- 我装的JBuilder9怎么没有EJB的开发包呀?
- jbuilder6开发ejb还要装什么东西?
- 请教:java.io.IOException: No such file or directory
- 求助mybatis3达人!!!!!熟悉的请进
一般应该在Servlet中把这种逻辑关系处理掉,如果非要在JSP中,就用: <c:if test="">分别写两种情况。问题2:
你名字既然一样,浏览器智能的认为直接从缓存中获取就行了啊,为啥还要去服务器端取?除非你的图片的HEAD信息中包含了no-cache等信息,要求服务器严禁缓存。验证码类的就经常会这样做问题3:
转到另一个Action,需要用 type="redirect-action" 或者chain。
如果用<s:if>怎么写啊,我的src中的值是用<s:property>来得到的,这个能嵌套吗?能不能像<s:iterator var="" value="">一样起个别名用啊?
<c:choose>
<c:when test="%{student.getSpath() != null}">
<img src="<s:property value='%{student.getSpath()}' />" width='240' height="240" />
</c:when>
<c:otherwise>
<img src="<s:property value='imageLoad/default.jpg' />" width='240' height="240" />
</c:otherwise>
</c:choose>
<s:set name="studentImagePath" value="%{student.getSpath()}" />
<s:if test="#studentImagePath != null">
<img src="<s:property value='#studentImagePath' />" width='240' height="240" />
</s:if>
<s:else>
<img src='imageLoad/default.jpg' width='240' height="240" />
</s:else>
但是当图片更新名字不改变的时候图片还是不能自动更新,都要手动刷新一下,因为我是用的学生的学号作为图片的存储名称的,不太适合用随机数的方法吧!
像if (request.getProtocol().compareTo("HTTP/1.0")==0)
response.setHeader("Pragma","no-cache");
if (request.getProtocol().compareTo("HTTP/1.1")==0)
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires",0);这些我都加了的,但是没有效果。
在这里想在确认一下:
struts2的action在每次接受新的数据之前都会把原来的数据清空吗?我观察了下 好像是这样的。
如果不是这样,并发情况下不就乱套了?检查下IE关于缓存的配置项,是否选择了“从不检查”?
实在不行就只能用我3楼说的:给文件名后面增加毫无意义的随机数当参数,比如: stuno.jpg?param=12323525