我真的很困惑,我的春季应用程序的地址是如何产生的.我按照教程,但现在我想改变地址,但我找不到这个地方.
目前的地址是:http:// localhost:8080/HelloWorld /
我在哪里可以将HelloWorld更改为其他内容?
我会为您提供您需要的任何代码.我有两个conf文件:web.xml,spring-servlet.xml,但它们中没有任何内容包含HelloWorld.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="hello.spring3.controller" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp" />
</bean>
</beans>
Run Code Online (Sandbox Code Playgroud)
和web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="spring3" version="3.0">
<display-name>Spring display name</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud) 这是一个例子:
http://www.tutorialspoint.com/java/java_using_singleton.htm
在查看第一个示例时,当用户写入:时Singleton.getInstance(),它会调出:
new Singleton()
我不知道它是什么单身,每当它创建一个新的单例对象时?
我理解第二个例子.如果singleton为null,则创建新对象,但在第一个示例中,它始终创建新对象??
那是怎么回事?
我有阵列 [1,2,1,2,3,4,3,4,1,2]
我想循环x次,每次向前移动每个元素1位置的数组:
所以下一个循环将是:
2.[2,1,2,3,4,3,4,1,2,1]
3.
[1,2,3,4,3,4,1,2,1,2]
等等....
我怎样才能像这样操纵数组呢?
编辑:
我的想法,但也许一些更好的技巧:
只需使用while循环遍历数组并使用for循环创建新数组.
for i in range(11)
array[i] = array[i-1]
Run Code Online (Sandbox Code Playgroud)
等等.伪代码
Public Sub SavePendleValues(ByVal row1 As Integer, ByVal row2 As Integer)
Run Code Online (Sandbox Code Playgroud)
打电话给它
For sheetrow = 2 To 15 ' number of rows to scan
SavePendleValues (sheetrow, sheetrow)
Next sheetrow
Run Code Online (Sandbox Code Playgroud)
得到错误: Compile error: Syntax error
当我取消注释该行时: SavePendleValues (sheetrow, sheetrow)
一切正常.
这是我如何定义我的jsp文件的loaction:
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
Run Code Online (Sandbox Code Playgroud)
但是我目前在一个文件夹中有太多的JSP文件......我将我的直接结构改为:
/WEB-INF/jsp/city/*.jsp
/WEB-INF/jsp/weather/*.jsp
Run Code Online (Sandbox Code Playgroud)
我该如何更改我的viewresolver以便找到这两个地方?
如果需要,请询问更多信息.
这是我的HTML代码:
<h3>Ilm selles linnas</h3>
<table>
<tr>
<th>id</th>
<th>city_id</th>
<th>temp</th>
<th>date</th>
</tr>
<div id="info"></div>
</table>
Run Code Online (Sandbox Code Playgroud)
这是我的脚本:
function(data) {
$('#info').empty();
var html = "";
for(var i = 0; i < data.length; i++) {
html += "<tr>"+
"<td>"+data[i].id+"</td>"+
"<td>"+data[i].city_id+"</td>"+
"<td>"+data[i].temperature+"</td>"+
"<td>"+data[i].date+"</td>"+
"</tr>";
}
$('#info').append(html);
}
Run Code Online (Sandbox Code Playgroud)
完成此操作后,在实际输出中会发生这种情况:

所以:
1)所有信息都高于表头(<th>标签)
2)所有信息都不在列中,而是一起粉碎
3)HTML源代码中没有显示任何信息.
我必须改变什么才能让它看起来应该如此?
随意问任何问题.
我有一个像这样的字符串:
06%2F27%2F2012%2C07%2F05%2F2012%2C06%2F29%2F2012%2C07%2F05%2F2012%2C07%2F06%2F2012%2C07%2F19%2F2012%2C07%2F06%2F2012%2C07%2F19%2F2012%2C07%2F05%2F2012%2C07%2F05%2F2012%2C07%2F20%2F2012%2C07%2F20%2F2012%2C07%2F27%2F2012%2C08%2F02%2F2012%2C07%2F20%2F2012%2C07%2F26%2F2012%2C08%2F03%2F2012%2C08%2F06%2F2012%2C08%2F06%2F2012%2C08%2F17%2F2012
Run Code Online (Sandbox Code Playgroud)
我希望它像这样拆分它的值:
%2F should be /
%2C marks the starting of new string
Run Code Online (Sandbox Code Playgroud)
所以价值观如下:
06/27/2012,07/05/2012等
我尝试为此创建一些正则表达式,但没有成功.
我试过的例子:
String phrase = "06%2F27%2F2012%2C07%2F05%2F2012%2C06%2F29%2F2012%2C07%2F05%2F2012%2C07%2F06%2F2012%2C07%2F19%2F2012%2C07%2F06%2F2012%2C07%2F19%2F2012%2C07%2F05%2F2012%2C07%2F05%2F2012%2C07%2F20%2F2012%2C07%2F20%2F2012%2C07%2F27%2F2012%2C08%2F02%2F2012%2C07%2F20%2F2012%2C07%2F26%2F2012%2C08%2F03%2F2012%2C08%2F06%2F2012%2C08%2F06%2F2012%2C08%2F17%2F2012";
String delims = "REGEX_GOES_HERE";
String[] tokens = phrase.split(delims);
Run Code Online (Sandbox Code Playgroud) 我喜欢这样的页面:
www.foo1.bar
www.foo2.bar
www.foo3.bar
.
.
www.foo100.bar
Run Code Online (Sandbox Code Playgroud)
我正在使用库jsoup并使用Thread同时连接到每个页面:
Thread matchThread = new Thread(task);
matchThread.start();
Run Code Online (Sandbox Code Playgroud)
每个任务,连接到这样的页面,并解析HTML:
Jsoup.connect("www.fooX.bar").timeout(0).get();
Run Code Online (Sandbox Code Playgroud)
获得大量的这些例外:
java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at sun.net.NetworkClient.doConnect(NetworkClient.java:158)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:388)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:523)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:227)
at sun.net.www.http.HttpClient.New(HttpClient.java:300)
at sun.net.www.http.HttpClient.New(HttpClient.java:317)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:404)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:391)
at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:157)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:146)
Run Code Online (Sandbox Code Playgroud)
jsoup是否只允许同时使用1个线程?或者我做错了什么?有关如何更快地连接到我的页面的任何建议,因为逐个进行需要很长时间.
编辑:
所有700个线程都使用这种方法,也许这就是问题所在.这个方法可以处理这个数量的线程还是单例?
private static Document connect(String url) {
Document doc = null;
try {
doc = Jsoup.connect(url).timeout(0).get(); …Run Code Online (Sandbox Code Playgroud) 我的pojo看起来像这样:
@Entity
@Table(name = "USERS")
public class User {
Run Code Online (Sandbox Code Playgroud)
当我保留名称时,一切正常,hibernate sql log:
create table users (id int8 not null, username varchar(255), primary key (id))
Run Code Online (Sandbox Code Playgroud)
当我删除注释时,我得到:
Hibernate: create table user (id int8 not null, username varchar(255), primary key (id))
19:24:43 [localhost-startStop-23] ERROR o.h.tool.hbm2ddl.SchemaExport - HHH000389: Unsuccessful: create table user (id int8 not null, username varchar(255), primary key (id))
19:24:43 [localhost-startStop-23] ERROR o.h.tool.hbm2ddl.SchemaExport - ERROR: syntax error at or near "user" Position: 14
Run Code Online (Sandbox Code Playgroud)
我试图使用它,因为它在我的xml中定义:
<property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy" />
Run Code Online (Sandbox Code Playgroud)
任何建议,为什么命名策略不起作用?