struts java 小技巧

[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>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章