String urlString = "http://www.nbc.com/Heroes/novels/downloads/Heroes_novel_001.pdf";
URL url = new URL(urlString);
if(/* Url does not return 404 */) {
System.out.println("exists");
} else {
System.out.println("does not exists");
}
urlString = "http://www.nbc.com/Heroes/novels/downloads/Heroes_novel_190.pdf";
url = new URL(urlString);
if(/* Url does not return 404 */) {
System.out.println("exists");
} else {
System.out.println("does not exists");
}
Run Code Online (Sandbox Code Playgroud)
这应该打印
exists
does not exists
Run Code Online (Sandbox Code Playgroud)
测试
public static String URL = "http://www.nbc.com/Heroes/novels/downloads/";
public static int getResponseCode(String urlString) throws MalformedURLException, IOException {
URL u = new URL(urlString);
HttpURLConnection huc = (HttpURLConnection) u.openConnection();
huc.setRequestMethod("GET"); …Run Code Online (Sandbox Code Playgroud) 我想知道如何在速度中逃避#.反斜杠似乎逃脱了它,但它也打印出来
这个:
\#\#
Run Code Online (Sandbox Code Playgroud)
打印:
\#\#
Run Code Online (Sandbox Code Playgroud)
我想要:
##
Run Code Online (Sandbox Code Playgroud) 我在tomcat/webapps文件夹下有两个应用程序.
tomcat/webapps/App1
tomcat/webapps/App2
Run Code Online (Sandbox Code Playgroud)
两个应用程序共享相同的库.例如存储在哪些中tomcat/webapps/App1/WEB-INF/lib.
两个库都在内存中加载了两次吗?
我应该把这些共享库放进去tomcat/server/lib吗?
我设法使用下一个代码,但必须有一个更简单的方法.
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:if test="${fn:length(attachments) > 0}">
<c:forEach var="attachment" items="${attachments}" varStatus="loopCount">
<c:if test="${loopCount.count eq 1}">
attachment.id
</c:if>
</c:forEach>
</c:if>
Run Code Online (Sandbox Code Playgroud) 我的应用程序托管在伦敦服务器中.我在西班牙马德里.所以时区是-2小时.
如何获取我的时区的当前日期/时间.
Date curr_date = new Date(System.currentTimeMillis());
Run Code Online (Sandbox Code Playgroud)
例如
Date curr_date = new Date(System.currentTimeMillis("MAD_TIMEZONE"));
Run Code Online (Sandbox Code Playgroud)
DateTimeZone zone = DateTimeZone.forID("Europe/Madrid");
DateTime dt = new DateTime(zone);
int day = dt.getDayOfMonth();
int year = dt.getYear();
int month = dt.getMonthOfYear();
int hours = dt.getHourOfDay();
int minutes = dt.getMinuteOfHour();
Run Code Online (Sandbox Code Playgroud) <table class="checkout itemsOverview">
<tr class="item">
<td>GR-10 Senderos</td>
<td><span class="value">15.00</span> €</td>
<td><input type="text" value="1" maxlength="2" class="quantity" /></td>
</tr>
<tr class="item">
<td>GR-10 Senderos<br/>GR-66 Camino de la Hermandad<br/>GR 88 Senderos del Jarama<br/>Camino del Cid</td>
<td><span class="value">45.00</span> €</td>
<td><input type="text" class="quantity" value="1" maxlength="2"/></td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用下一个代码来获取每个项目的价值和数量.
$("tr.item").each(function(i, tr) {
var value = $(tr + " span.value").html();
var quantity = $(tr + " input.quantity").val();
});
Run Code Online (Sandbox Code Playgroud)
它不起作用.谁能帮我?
我需要在Java字符串之间执行Diffs.我希望能够使用原始字符串和diff版本重建字符串.有没有人用Java做过这个?你用什么图书馆?
String a1; // This can be a long text
String a2; // ej. above text with spelling corrections
String a3; // ej. above text with spelling corrections and an additional sentence
Diff diff = new Diff();
String differences_a1_a2 = Diff.getDifferences(a,changed_a);
String differences_a2_a3 = Diff.getDifferences(a,changed_a);
String[] diffs = new String[]{a,differences_a1_a2,differences_a2_a3};
String new_a3 = Diff.build(diffs);
a3.equals(new_a3); // this is true
Run Code Online (Sandbox Code Playgroud) 我将Hibernate与MySQL 5.1.30一起使用.
我有下一个库:
我使用hibernate.cfg.xml进行配置:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/fooDatatbase</property>
<property name="connection.username">foo</property>
<property name="connection.password">foo123</property>
<!-- Use the C3P0 connection pool provider -->
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_periods">3000</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout --> …Run Code Online (Sandbox Code Playgroud) 有时我会在Chrome中破坏背景.我没有得到任何其他浏览器的此错误.
这是负责身体背景颜色的简单CSS线:
body
{
background: black;
color: white;
font-family: Chaparral Pro, lucida grande, verdana, sans-serif;
}
Run Code Online (Sandbox Code Playgroud)
这正是我遇到这个问题的原因.我点击了Gmail电子邮件中包含的链接,但我得到了错误(没有背景信息).然后我刷新页面,背景完全着色.
怎么解决这个问题?