struts java 小技巧

来源:互联网 发布:淘宝网毛衣女新款开衫 编辑:程序博客网 时间:2024/06/05 07:56

[1]. struts2 类里面获取客户端ip
import org.apache.struts2.ServletActionContext;
//得到用户IP地址
String ip = ServletActionContext.getRequest().getRemoteAddr();
[2]. 获得web工程路径Jsp页面:
${pageContext.request.contextPath}
如:
<link href="${pageContext.request.contextPath}/swspt/css/main.css" rel="stylesheet" type="text/css" />


[2]. Struts2,google浏览器出现TypeError: object is not a function错误原因及解决方法

Jsp页面的<s:div  ….>标签一定要指明id值,不然会出错。也可以用普通div标签。比如显示项目描述的时候
<div Style="border:1px;"><pre style="overflow: hidden; word-wrap: break-word; width: 680px;"><s:property value="fsyw.conent" /></pre>
</div>