我有一个模型,它是一个需要处理复杂和简单元素的数组:
{
"object" :[
"element1.html",
"element2.html",
{
"url:"element3.html",
"title" : "Title 3"
},
"element4.html",
"element5.html"
]
}
Run Code Online (Sandbox Code Playgroud)
有没有办法制作一个可以处理angularjs中简单和复杂元素的选择(显示复杂的url)?
方法1
我的意思是这样的:
ng-model="(object[$index].url ? object[$index].url : object[$index])"
Run Code Online (Sandbox Code Playgroud)
方法2
创建一个规范化对象,该对象具有每个对象的复杂结构,其中包含空数组和指示是简单还是复杂的文件类型.
我可以用角度制作一些魔法来避免第二种方法吗?
谢谢!
使用spring数据JPA,我试图进行这种查询(它更复杂,这是一个简单的例子)
@Query(nativeQuery = true,
value = "SELECT * FROM events WHERE typeId IN (?1)")
List<Event> findEventsByType(List<Integer> types);
Run Code Online (Sandbox Code Playgroud)
当我启动查询时,异常会引发:
org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of java.util.ArrayList. Use setObject() with an explicit Types value to specify the type to use.
Run Code Online (Sandbox Code Playgroud)
我已经尝试了List <Integer>,Integer [],Object []和String但它不能正常工作......
我不能通过值列表吗?
进行此类查询的最佳方法是哪种?
谢谢!
我试图用jQuery调用我的Java RESTFUL API有点困难.
调试我发现调用了OPTIONS和GET方法但是当GET方法在服务器中完成时,不会检索json并且在broswer中引发错误.
选项请求
OPTIONS /PTGServices/ptgapi/v1/clients/1/ngos HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Cache-Control: max-age=0
Access-Control-Request-Method: GET
Origin: http://localhost:8181
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36
Access-Control-Request-Headers: accept, cache-control, x-custom-1, x-custom-2, authorization
Accept: */*
Referer: http://localhost:8181/jquerysample/local/index.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: es-ES,es;q=0.8,en;q=0.6
Run Code Online (Sandbox Code Playgroud)
选项响应
HTTP/1.1 204 Sin Contenido
Server: Apache-Coyote/1.1
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://localhost:8181
Access-Control-Allow-Methods: GET, POST, PUT
Access-Control-Allow-Headers: Authorization,Cache-control,Content-Type,Origin,X-requested-with,X-custom-1,X-custom-2,WithCredentials
Access-Control-Max-Age: 60
Date: Mon, 20 Jan 2014 14:49:25 GMT
Run Code Online (Sandbox Code Playgroud)
获得请求
Accept:*/*
Authorization:Basic dXNlcjp1c2Vy
Cache-Control:no-cache
Origin:http://localhost:8181
Referer:http://localhost:8181/jquerysample/local/index.html
User-Agent:Mozilla/5.0 (Windows NT …Run Code Online (Sandbox Code Playgroud) 使用Spring Data JPA我在同一个事务中有下一个流程(REQUIRES_NEW):
使用此Spring Data JPA存储库方法删除一组用户的预测.
@Query(value = "DELETE FROM TRespuestaUsuarioPrediccion resp WHERE resp.idEvento.id = :eventId AND resp.idUsuario.id = :userId")
@Modifying
void deleteUserPredictions(@Param("userId") int userId, @Param("eventId") int eventId);
Run Code Online (Sandbox Code Playgroud)插入新用户的预测并保存主对象(事件).
eventRepository.save(event);
Run Code Online (Sandbox Code Playgroud)当这个服务完成时,提交是由AOP完成的,但只能在第一次尝试时...而不是在下一个...
如何在不迭代事件的预测条目并更新内部的每个条目的情况下管理这种情况?
UPDATE
我尝试了它,它不起作用(适配器插入我之前删除的对象):
@Transactional(propagation=Propagation.REQUIRES_NEW, rollbackFor=PlayTheGuruException.class)
private void updateUserPredictions(final TUsuario user, final TEvento event, final SubmitParticipationRequestDTO eventParticipationRequestDTO)
{
eventRepository.deleteUserPredictions(user.getId(), event.getId());
EventAdapter.predictionParticipationDto2Model(user, event, eventParticipationRequestDTO);
eventRepository.save(event);
}
Run Code Online (Sandbox Code Playgroud) Inboud网关:
<int-http:inbound-gateway id="inbound.gateway"
request-channel="transactional.channel.input"
reply-channel="channel.output"
error-channel="channel.error"
request-payload-type="java.lang.String"
</int-http:inbound-gateway>
Run Code Online (Sandbox Code Playgroud)
建议定义:
<tx:advice id="advice">
<tx:attributes>
<tx:method name="send" propagation="REQUIRES_NEW" rollback-for="MyClassException"/>
</tx:attributes>
</tx:advice>
Run Code Online (Sandbox Code Playgroud)
建议配置:
<aop:config>
<aop:advisor advice-ref="advice" pointcut="bean(transactional.channel.input)"/>
</aop:config>
Run Code Online (Sandbox Code Playgroud)
需要交易的链:
<int:chain input-channel="transactional.channel.input" output-channel="non.transactional.channel.input>
<int:service-activator ref="v1.registerUser.service" method="registerUser"/>
<int:service-activator ref="v1.saveObject.service" method="saveObject"/>
</int:chain>
Run Code Online (Sandbox Code Playgroud)
需要事先执行的链以获取在最后一个转换链步骤中生成的对象id:
<int:chain input-channel="non.transactional.channel.input" output-channel="channel.output">
<int:service-activator ref="v1.getObjectId.service" method="getObjectId"/>
<int:object-to-json-transformer/>
</int:chain>
Run Code Online (Sandbox Code Playgroud)
有了这个简化的上下文,当我访问getObjectId服务中的id时,事务尚未执行.
因此,事务似乎在入站网关输出级别提交.
我在我的Java类中使用GroovyClassLoader来解析某个(理想情况下很复杂的)groovy文件(将在下一步执行):
在MyClass.java中调用
final Class parsedClass = groovyClassLoader.parseClass(groovyFile);
Run Code Online (Sandbox Code Playgroud)
知道:
GroovyFile.groovy进口
import com.my.import.one.Import1DTO
import com.my.import.two.Import2DTO
import com.my.import.three.Import3DTO
import com.my.import.four.Import4DTO
import com.my.import.five.Import5DTO
Run Code Online (Sandbox Code Playgroud)
当调用parseClass方法时,此异常引发:
例外
unable to resolve class com.my.import.one.Import1DTO;
unable to resolve class com.my.import.two.Import2DTO;
unable to resolve class com.my.import.three.Import3DTO;
unable to resolve class com.my.import.four.Import4DTO;
unable to resolve class com.my.import.five.Import5DTO;
Run Code Online (Sandbox Code Playgroud)
在解析基类之前,我是否可以获得我期望的行为而不解析每个导入类?
谢谢!
在我们当前的应用程序中,我们以这种方式使用Spring AMQP:
<rabbit:connection-factory id="cachingConnectionFactory"
username="${rabbitmq.connection.username}"
password="${rabbitmq.connection.password}"
host="${rabbitmq.connection.host}"
port="${rabbitmq.connection.port}"
executor="rabbitmqPoolTaskExecutor"
requested-heartbeat="${rabbitmq.connection.requested-heartbeat}"
channel-cache-size="${rabbitmq.connection.channel-cache-size}"
virtual-host="${rabbitmq.connection.virtual-host}" />
<rabbit:admin id="adminRabbit"
connection-factory="cachingConnectionFactory"
auto-startup="true" />
<rabbit:template id="rabbitTemplate"
connection-factory="cachingConnectionFactory"
exchange="v1.general.exchange"
message-converter="jsonMessageConverter"
encoding="${rabbitmq.template.encoding}"
channel-transacted="${rabbitmq.template.channel-transacted}" />
<rabbit:queue id="v1.queue.1" name="v1.queue.1" />
<rabbit:queue id="v1.queue.2" name="v1.queue.2" />
<rabbit:queue id="v1.queue.3" name="v1.queue.3" />
<fanout-exchange name="v1.general.exchange" xmlns="http://www.springframework.org/schema/rabbit" >
<bindings>
<binding queue="v1.queue.1" />
<binding queue="v1.queue.2" />
<binding queue="v1.queue.3" />
</bindings>
</fanout-exchange>
<listener-container xmlns="http://www.springframework.org/schema/rabbit"
connection-factory="cachingConnectionFactory"
message-converter="jsonMessageConverter"
task-executor="rabbitmqPoolTaskExecutor"
auto-startup="${rabbitmq.listener-container.auto-startup}"
concurrency="${rabbitmq.listener-container.concurrency}"
channel-transacted="${rabbitmq.listener-container.channel-transacted}"
prefetch="${rabbitmq.listener-container.prefetch}"
transaction-size="${rabbitmq.listener-container.transaction-size}" >
<listener id="v1.listener.queue.1" ref="listener1" method="handleMessage" queues="v1.queue.1" />
<listener id="v1.listener.queue.2" ref="listener2" method="handleMessage" queues="v1.queue.2" />
<listener id="v1.listener.queue.3" ref="listener3" …Run Code Online (Sandbox Code Playgroud) 我正在寻找是否可以在Java 7中实现这一点:
现在,我在几个服务中都有这样的函数,第三个参数在每个服务中都是不同的:
final RequestDTO1 requestDTO = (RequestDTO1) getDTO(param, RequestDTO1.class);
final RequestDTO2 requestDTO = (RequestDTO2) getDTO(param, RequestDTO2.class);
final RequestDTO3 requestDTO = (RequestDTO3) getDTO(param, RequestDTO3.class);
Run Code Online (Sandbox Code Playgroud)
这是getDTO签名:
protected Object getMessage(Object param, Class clazz);
Run Code Online (Sandbox Code Playgroud)
有一些方法可以指示getDTO函数我想要返回第三个参数指示的类的对象而不使用转换吗?
final RequestDTO1 requestDTO = getDTO(param, RequestDTO1.class);
final RequestDTO2 requestDTO = getDTO(param, RequestDTO2.class);
final RequestDTO3 requestDTO = getDTO(param, RequestDTO3.class);
Run Code Online (Sandbox Code Playgroud) 我正在尝试将一个弹簧启动应用程序部署到一个EB工作层,但似乎EB还没有准备好管理这种类型的项目.
我是否必须从我的春季启动应用程序强制生成.war?
谢谢!
java-7 ×2
javascript ×2
jpa ×2
ajax ×1
angularjs ×1
cors ×1
eclipselink ×1
groovy ×1
groovyshell ×1
java ×1
jpa-2.0 ×1
jpa-2.1 ×1
jquery ×1
spring ×1
spring-4 ×1
spring-boot ×1
spring-data ×1
transactions ×1