?41.Bootstrap換行。
col-md-10和col-md-2。
這2個div按說應該在一行的,結果col-md-2換行了。
看看樣式,發現有多余的“margin-left: 1px;"。
42.Service實現類定義了一個“自動調度進行刷新”的方法。
@Override
@Scheduled(cron = "0 0/10 * * * ? ")
// 每10分鐘一次
public void refreshBannerPhoto() {
bannerPhotoList = photoDao.find(searchBannerForm());
}
需要在接口類中,也定義一個方法。
void refreshBannerPhoto();
要不然可能出現以下錯誤。
@Scheduled method 'refreshBannerPhoto' found on bean target class 'PhotoServiceImpl',?
but not found in any interface(s) for bean JDK proxy. Either pull the method up to an interface?
or switch to subclass (CGLIB) proxies by setting proxy-target-class/proxyTargetClass attribute to 'true'
43.Nginx和Tomcat配置疑惑。
需求:一個Tomcat下,部署2個項目。
2個項目使用不同的域名訪問。
并且處于實際考慮,A項目必須部署在root下,從而解決圖片等路徑問題。
在Java中,項目名稱是個很煩人的東西。
A項目
server {
37 ? ? ? ? listen 80;
38 ? ? ? ? server_name fansunion.cn www.fansunion.cn blog.fansunion.cn;
39 ? ? ??
51 ? ? ? ?location / {
52 ? ? ? ? ? ?proxy_pass ??http://localhost:8080;
53 ? ? ? ?}
B項目
server{
76 ? ? ? ?listen 80;
77 ? ? ? ?server_name soft.fansunion.cn;
78 ? ? ? ?location / {
79 ? ? ? ? ? ?proxy_pass?http://localhost:8080/soft;
80 ? ? ? }
81
82 ? ?}
期望:訪問?http://soft.fansunion.cn,訪問http://localhost:8080/soft這個項目。
結果:http://localhost:8080/soft,訪問的是http://localhost:8080/根目錄下的項目。
折衷處理,繞過去,把soft項目部署到另外一個Tomcat的根目錄下,這個Tomcat監聽9080等不同的端口。
問題:多一個Tomcat,多使用了100多M內存額。
44.使用JSONP解決跨域問題。
后端Java代碼備份:
// 對外提供的服務接口,演示用jsonp解決跨域問題
// TODO jsoncallback是可選的,categoryid->categoryId
@RequestMapping(value = "recentpost")
public void recentPost(Integer categoryid, String jsoncallback,
Integer count, Model model, HttpServletResponse response) {
if (categoryid == null) {
categoryid = DEFAULT_CATEGORY;
}
List<Post> list = postService.listRecent(categoryid, count);
String str = JSONObject.toJSONString(list);
str = jsoncallback + "(" + str + ")";
super.returnMessage(response, str);
}
45.類型轉換空指針異常。
Integer ispage;
if (ispage == 1){
}
ispage是null。
這說明,Integer類型的ispage被轉換成int,JDK內部轉換時,報錯。
46.KindEditor獲得html和text內容。
方法一:editor.sync();
$("#content).val();
方法二:
html格式內容,editor.html();
文本格式內容,editor.text();
47.ActiveMq的啟動。
啟動ActiveMq
cd /activemq/bin
經常出現問題的啟動方式: ./bin/activemq start
更好的方式:使用bin目錄下的linux-x86-64目錄下的activemq啟動
./bin/linux-x86-64/activemq start
48.Spring注入屬性的值到字段中。
@Value("${loginCookieName}")
private static final String loginCookieName = "cookieName";
a.properties
loginCookieName=abc
49.權限漏洞。
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**/*.html" />
<mvc:mapping path="/**/*.json" />
<mvc:exclude-mapping path="/login.html*"/>
<bean class="com.p2p.backend.interceptors.BackendLoginInterceptor">
<property name="loginUrl">
<value>${backendLoginUrl}</value>
</property>
</bean>
</mvc:interceptor>
<mvc:interceptor>
<mvc:mapping path="/**" />
<bean class="com.p2p.base.interceptors.BackendPermissionInterceptor">
</bean>
</mvc:interceptor>
</mvc:interceptors>
重新看了下權限,發現有漏洞,我的火眼金睛不是瞎吹的。
訪問post.json,沒有登錄,沒有權限,按說返回false。
但是,post.json2,就繞過去了。
另外一個原因是,SpringMVC的DispatchServlet攔截的是“/*”所有,而不是只攔截/*.html和/*.json。
50.Freemarker的base問題。
http://login.jiutianniao.com/
實際后端響應的是?http://login.jiutianniao.com/login。
靜態資源的路徑是:
${base}/static/
通過Nginx代理之后,${base}是http://login.jiutianniao.com/login/static。
訪問報錯了。
因為,通過Nginx訪問的地址是http://login.jiutianniao.com/static。
這個地址映射到后端http://login.jiutianniao.com/login/static。
解決辦法:base變量也做成可配置的。
userDomain=http://p2p.jiutianniao.com:8080
靜態資源的路徑是:
${userDomain}/static/
String contextPath = request.getContextPath();
model.put("base", contextPath);
總結:${base}在沒有代理的情況下,很好。
有Nginx代理之后,目錄訪問會不正常。