簡體   English   中英

在 JSP 上使用第 3 方 Java 庫

[英]Using 3rd Party Java Libraries on JSP

如何在JSP上使用 Twitter4J 等第三方庫?

這有點惡心,但你能不能只在你的 JSP 中內聯適當的 Java ?

<%
   // This should really be in a servlet
   // Twitter4J code from their example 
   Twitter twitter = new TwitterFactory().getInstance();
   List<Status> statuses = twitter.getFriendsTimeline();
   System.out.println("Showing friends timeline.");
   for (Status status : statuses) {
       System.out.println(status.getUser().getName() + ":" +
                        status.getText());
   }
%>

確保 Twitter4J jar 及其所有依賴項都在您的 WEB-INF/lib/ 文件夾中。 然后,如果可能的話,認真考慮不要在 JSP 中這樣做!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM