我正在努力返回JSON数据并将其转换为可观察的数据.数据以JSON格式返回,但似乎没有分配给observable.有人可以帮忙吗?我猜这个问题是在ajax调用的成功部分:
<script type="text/javascript">
function StandingsViewModel() {
var self = this;
self.standings = ko.observableArray();
self.DivisionName = ko.observable('');
self.afceast = ko.computed(function () {
return ko.utils.arrayFilter(self.standings(), function (i) {
return "AFC East" == i.DivisionName;
});
});
self.afccentral = ko.computed(function () {
return ko.utils.arrayFilter(self.standings(), function (i) {
return "AFC Central" == i.DivisionName;
});
});
self.afcwest = ko.computed(function () {
return ko.utils.arrayFilter(self.standings(), function (i) {
return "AFC West" == i.DivisionName;
});
});
self.nfceast = ko.computed(function () {
return ko.utils.arrayFilter(self.standings(), function (i) {
return "NFC East" …Run Code Online (Sandbox Code Playgroud) 如何隐藏.jsp扩展名或更改URL上的显示名称?
我正在使用servlet-jsp通信.我的web.xml代码是
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>pub</servlet-name>
<jsp-file>/publications.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>pub</servlet-name>
<url-pattern>/publications</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>SciArchive</servlet-name>
<servlet-class>controller.SciArchiveController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SciArchive</servlet-name>
<url-pattern>*.sci</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>home.jsp</welcome-file>
</welcome-file-list>
</web-app>
Run Code Online (Sandbox Code Playgroud)
我想隐藏的URL的.jsp extenstion ..../SciArchive/publications.jsp
到..../SciArchive/publications
我通过这一行获得了一个对象:
val product_array:Option[Any] = scala.util.parsing.json.JSON.parseFull(products_json)
Run Code Online (Sandbox Code Playgroud)
打印出来的对象如下所示:
(product1Id,Map(product_picture -> https://upload.wikimedia.org/wikipedia/commons/thumb/7/73/IPhone_3G.png/250px-IPhone_3G.png, product_price -> 299.99, recipient_picture -> https://www.allianz.com/static-resources/de/presse/mediendatenbank/people/v_1338807733000/zimerer_portrait_small_326x217.jpg, product_amount_gifted -> 100.00, recipient_username -> jDoe, product_name -> iPhone 3G, recipient_id -> 12345))(product2Id,Map(product_picture -> https://upload.wikimedia.org/wikipedia/en/thumb/7/7c/1stGen-iPad-HomeScreen.jpg/220px-1stGen-iPad-HomeScreen.jpg, product_price -> 399.99, recipient_picture -> https://image1.masterfile.com/em_w/05/11/94/400-05119409w.jpg, product_amount_gifted -> 200.00, recipient_username -> MJohnson, product_name -> iPad, recipient_id -> 67890))
Run Code Online (Sandbox Code Playgroud)
如何循环遍历数组/对象以提取键和值?
更新:
当我尝试遍历对象时,它会将空值发送到键和值,如下所示:
for((key, value) <- product_array) {
}
Run Code Online (Sandbox Code Playgroud)
这是原始的json:
{
"product1Id":{
"product_name":"iPhone 3G",
"product_price":"299.99",
"product_amount_gifted":"100.00",
"product_picture":"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/7\/73\/IPhone_3G.png\/250px-IPhone_3G.png",
"recipient_picture":"https:\/\/www.allianz.com\/static-resources\/de\/presse\/mediendatenbank\/people\/v_1338807733000\/zimerer_portrait_small_326x217.jpg",
"recipient_username":"jDoe",
"recipient_id":"12345"
},
"product2Id":{
"product_name":"iPad",
"product_price":"399.99",
"product_amount_gifted":"200.00",
"product_picture":"https:\/\/upload.wikimedia.org\/wikipedia\/en\/thumb\/7\/7c\/1stGen-iPad-HomeScreen.jpg\/220px-1stGen-iPad-HomeScreen.jpg",
"recipient_picture":"https:\/\/image1.masterfile.com\/em_w\/05\/11\/94\/400-05119409w.jpg",
"recipient_username":"MJohnson",
"recipient_id":"67890"
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用hibernate-maven-plugin引导数据库,该数据库使用在执行它的maven模块中扫描的模型。
不幸的是,它在休眠抛出以下内容时停止:
org.hibernate.tool.schema.spi.SchemaManagementException: SQL strings added more than once for: reference_data_source.UK-UK_9ec6wdvyj3mjagiptcnrq2txv
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.checkExportIdentifier(SchemaCreatorImpl.java:299)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:255)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:128)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:199)
Run Code Online (Sandbox Code Playgroud)
因此,我有两个持久性单元,并且两个表中都存在一些表。Hibernate似乎将其解释为相同的表,因此,当它尝试存储相同的索引时,对于另一个模式,它无法认为它是重复的。他们的代码可以在这里找到。
我不确定如何解决这个问题,无论如何配置休眠hbm2ddl来跟踪这些不同的持久性单元?
这是hibernate-maven-plugin的配置:
<plugin>
<groupId>de.juplo</groupId>
<artifactId>hibernate-maven-plugin</artifactId>
<version>2.0.0</version>
<configuration>
<detail>true</detail>
<persistenceUnit>mainPersistenceUnit</persistenceUnit>
<driver>com.mysql.jdbc.Driver</driver>
<dialect>org.hibernate.dialect.MySQL5Dialect</dialect>
<force>true</force>
<url><![CDATA[jdbc:mysql://localhost/auto_bootstrap_schema]]></url>
<username>user</username>
<password>pass</password>
</configuration>
<executions>
<execution>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector-java.version}</version>
</dependency>
</dependencies>
</plugin>
Run Code Online (Sandbox Code Playgroud)