在编译JSP模板期间,我得到以下异常:
getFriendImage()不是方法
我尝试过重建课程,但没有结果。 src中的项目是指向运行正常的图像的链接。
package classes;
public class Friends {
private String username;
private String friendname;
private String complete;
private String datestring;
private String user_image;
private String friendImage;
private String online;
public Friends(String username, String friendname, String complete,
String datestring, String user_image,
String friendImage, String online) {
this.username = username;
this.friendname = friendname;
this.complete = complete;
this.datestring = datestring;
this.user_image = user_image;
this.friendImage = friendImage;
this.online = online;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getFriendname() {
return friendname;
}
public void setFriendname(String friendname) {
this.friendname = friendname;
}
public String getComplete() {
return complete;
}
public void setComplete(String complete) {
this.complete = complete;
}
public String getDatestring() {
return datestring;
}
public void setDatestring(String datestring) {
this.datestring = datestring;
}
public String getUser_image() {
return user_image;
}
public void setUser_image(String user_image) {
this.user_image = user_image;
}
public String getFriendImage() {
return friendImage;
}
public void setFriendImage(String friendImage) {
this.friendImage = friendImage;
}
public String getOnline() {
return online;
}
public void setOnline(String online) {
this.online = online;
}
}
session.setAttribute("friendsList", friendsList);
JSP模板
<ul id="friends_list">
<c:forEach var="item" items="${friendsList}">
<li class="friend_item"><img class="friend_list_image"
src="${friendsList.getFriendImage()}"
alt="friend_image"/>
<label>${friendsList.getFriendname()}</label>
<img class="message_icon" src="Images/Message.png"
alt="Message_Icon" title="Message" onclick="message_friend()"/>
</li>
</c:forEach>
</ul>
答案 0 :(得分:1)
您可能希望访问Merging result:SUCCESS
Merged manifest saved to /home/paneladm/my-react-native-app/node_modules/react-native-config/android/build/intermediates/bundles/release/AndroidManifest.xml
:react-native-config:processReleaseManifest (Thread[main,5,main]) completed. Took 0.116 secs.
:react-native-config:processReleaseResources (Thread[main,5,main]) started.
:react-native-config:processReleaseResources
Executing task ':react-native-config:processReleaseResources' (up-to-date check took 0.016 secs) due to:
Output file /home/paneladm/my-react-native-app/node_modules/react-native-config/android/build/intermediates/incremental/processReleaseResources has changed.
Output file /home/paneladm/my-react-native-app/node_modules/react-native-config/android/build/generated/source/r/release has changed.
Output file /home/paneladm/my-react-native-app/node_modules/react-native-config/android/build/generated/source/r/release/com has been removed.
All input files are considered out-of-date for incremental task ':react-native-config:processReleaseResources'.
Starting process 'command '/home/paneladm/Android-sdk/build-tools/23.0.1/aapt''. Working directory: /home/paneladm/my-react-native-app/node_modules/react-native-config/android Command: /home/paneladm/Android-sdk/build-tools/23.0.1/aapt package -f --no-crunch -I /home/paneladm/Android-sdk/platforms/android-23/android.jar -M /home/paneladm/my-react-native-app/node_modules/react-native-config/android/build/intermediates/manifests/aapt/release/AndroidManifest.xml -S /home/paneladm/my-react-native-app/node_modules/react-native-config/android/build/intermediates/res/merged/release -m -J /home/paneladm/my-react-native-app/node_modules/react-native-config/android/build/generated/source/r/release --custom-package com.lugg.ReactNativeConfig --non-constant-id -0 apk --output-text-symbols /home/paneladm/my-react-native-app/node_modules/react-native-config/android/build/intermediates/bundles/release --no-version-vectors
:react-native-config:processReleaseResources FAILED
:react-native-config:processReleaseResources (Thread[main,5,main]) completed. Took 0.123 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-config:processReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
项目上的getFriendImage()
而不是整个列表。如果是这样,您应该像这样访问它
Friend
同样适用于应该
的src="${item.getFriendImage()}"
label
此外,你不应该以复数形式调用班级<label>${item.getFriendname()}</label>
。使用Friends
构建一个新的(单个)朋友是非常误导的,所以单数new Friends()
很好。
答案 1 :(得分:1)
你通常不应该像那样访问那些方法。通常你应该做的只是使用你在Friends类中声明的字段名称来访问它们,前提是你事先设置了这些变量。
此外,如果您在<c:forEach
中提供${item.somefieldname}
,则应使用<ul id="friends_list">
<c:forEach var="item" items="${friendsList}">
<li class="friend_item">
<img class="friend_list_image" src="${item.friendImage}" alt="friend_image"/>
<label>${item.friendname}</label>
<img class="message_icon" src="Images/Message.png" alt="Message_Icon" title="Message" onclick="message_friend()"/>
</li>
</c:forEach>
</ul>
private String username;
private String friendname;
private String complete;
private String datestring;
private String user_image;
private String friendImage; //capitalized here, be careful!
private String online;
还要注意大写:
{{1}}