使用bootstrap list-inline进行角度ng-repeat(angular ng-repeat with bootstrap list-inline)
<body ng-app="" ng-init="names=['james', 'sean', 'emmanuel']"> <div class="container"> <h2>Angular ng-repeat demo</h2> <ul class="list-inline" ng-repeat="name in names"> <li> {{ name }} </li> </ul> </div>
我是角度和自举的新手。 上面的代码不会将名称放在一行上。 有什么建议吗?
ps:list-line是一个bootstrap css类
<body ng-app="" ng-init="names=['james', 'sean', 'emmanuel']"> <div class="container"> <h2>Angular ng-repeat demo</h2> <ul class="list-inline" ng-repeat="name in names"> <li> {{ name }} </li> </ul> </div>
I'm new to angular and bootstrap. The code above does not place the names on a single line. Any suggestion?
ps: list-line is a bootstrap css class
原文:https://stackoverflow.com/questions/27966589
最满意答案
好吧,所以我设法通过基本上遵循斯蒂芬C的建议来解决这个问题,但我想我会发布更多细节以防其他人在同一条船上。 首先,我实际上从泽西指南开始了几个部分,特别是这一部分:
https://jersey.java.net/documentation/latest/user-guide.html#d0e6825
显然我使用Jersey作为javax.ws.rs.client,我使用Genson进行JSON反序列化。 因此,我实现了以下类来实现MessageBodyReader:
public class BTCEURTradeMessageBodyReader implements MessageBodyReader<BTCEURTrades> { final org.slf4j.Logger logger = LoggerFactory.getLogger(BTCEURTradeMessageBodyReader.class); @Override public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { logger.info("isReadable being checked for: {} and media type: {}", type, mediaType); return type == BTCEURTrades.class; } @Override public BTCEURTrades readFrom(Class<BTCEURTrades> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { logger.info("readFrom being called for: {}", type); BTCEURTrades btceurTrades; try { btceurTrades = new Genson().deserialize(entityStream, type); } catch(Exception e) { logger.error("Error processing JSON reponse.", e); throw new ProcessingException("Error processing JSON reponse."); } return btceurTrades; } }
然后,在创建客户端后,将其注册,如下所示:
client = ClientBuilder.newClient(); client.register(BTCEURTradeMessageBodyReader.class);
Okay so I managed to figure it out by essentially following Stephen C's advice but thought I'd post a few more details in case anyone else is in the same boat. First I actually started from the Jersey guide a few sections back, specifically this one:
https://jersey.java.net/documentation/latest/user-guide.html#d0e6825
Obviously I am using Jersey for the javax.ws.rs.client and I am using Genson to do the JSON deserialisation. As a result I have implemented the following class to implement a MessageBodyReader:
public class BTCEURTradeMessageBodyReader implements MessageBodyReader<BTCEURTrades> { final org.slf4j.Logger logger = LoggerFactory.getLogger(BTCEURTradeMessageBodyReader.class); @Override public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { logger.info("isReadable being checked for: {} and media type: {}", type, mediaType); return type == BTCEURTrades.class; } @Override public BTCEURTrades readFrom(Class<BTCEURTrades> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { logger.info("readFrom being called for: {}", type); BTCEURTrades btceurTrades; try { btceurTrades = new Genson().deserialize(entityStream, type); } catch(Exception e) { logger.error("Error processing JSON reponse.", e); throw new ProcessingException("Error processing JSON reponse."); } return btceurTrades; } }
This then gets registered with the client after it is created as follows:
client = ClientBuilder.newClient(); client.register(BTCEURTradeMessageBodyReader.class);
相关问答
更多-
(根据@peeskillet的评论)我取代了这个:
org.glassfish.jersey.media jersey-media-json-jackson 2.17 com.fasterxml.jackson.jaxrs ... -
好吧,所以我设法通过基本上遵循斯蒂芬C的建议来解决这个问题,但我想我会发布更多细节以防其他人在同一条船上。 首先,我实际上从泽西指南开始了几个部分,特别是这一部分: https://jersey.java.net/documentation/latest/user-guide.html#d0e6825 显然我使用Jersey作为javax.ws.rs.client,我使用Genson进行JSON反序列化。 因此,我实现了以下类来实现MessageBodyReader: public class BTCEUR ...
-
Spring-Jersey-Jackson-JSON:由索引包装的数组元素(Spring-Jersey-Jackson-JSON: Array element wrapped by index)[2022-06-14]
如果要返回一个对象数组,json格式应如下所示 [ { "type":"AQUISITION_DT", "value":"2013-2-1", "stats":{ "total":91, "used":4 } }, { "type":"AQUISITION_DT", "value":"2013-1-1", "stats":{ "total":24, ... -
在JUnit中使用Jackson反序列化列表(Jersey客户端)(Deserialize List with Jackson in JUnit (Jersey Client))[2022-08-09]
可能为时已晚,你找到了解决方案,但这里是其他可能遇到同样问题的人。 确保在创建客户端之前在客户端配置上注册JacksonFeature,代码示例如下。 ClientConfig cc = new ClientConfig().register(new JacksonFeature()); Client client = ClientBuilder.newClient(cc); WebTarget target = client.target(url); Probably too late and you ... -
我尝试使用Jackson,并且能够在一个衬里中构建JSON对象。 可能你正在寻找什么。 import java.io.IOException; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jacks ...
-
我找到了解决问题的方法。 需要进行一些更改: 在请求的jsonData对象中,不应该有status根属性。 只是对象本身: jsonData: { id: 1, description: 'Description' }, 我还从我的方法声明中删除了JAXBElement
。 它只接收Status status对象。 最后, Status class不需要@XmlRootElement注释。 然而,它需要@JsonCreator注释超过其默认(空)构造函数。 I found ... -
无法获得jersey 2应用程序使用自定义jackson XmlMapper(Cannot get jersey 2 application to use custom jackson XmlMapper)[2021-11-08]
所以有一些事情。 首先,您需要的不仅仅是核心Jackson xml依赖项,您需要实际的jaxrs提供程序com.fasterxml.jackson.jaxrs jackson-jaxrs-xml-provider ${jackson2.version} -
您还可以使用BeanValidationApi (javax.validation.constraints),然后使用@NotNull,@Pattern等注释您的字段@NotNull,@Pattern还提供Bean验证支持 You can also BeanValidationApi (javax.validation.constraints) and then annotate your fields with @NotNull,@Pattern, etc. Jersey also provides Be ...
-
通常它应该正常工作,这意味着JAXB支持所需的所有提供程序都应该通过自动发现自动注册。 出于某种原因,自动发现不适合您。 我能想到的唯一能让它无法工作的是你明确地禁用它 ,或者你正在构建一个超级jar,并且不包含META-INF服务文件 。 在任何情况下,如果您想自己手动注册提供商(否则会被AutoDiscoverable注册 ),您可以这样做。 只需使用JaxbMessagingBinder注册JaxbMessagingBinder和JaxbParamConverterBinder (作为实例 - 而不是 ...
-
假设您有一个正在读取结果的根对象,您可以在jsonObj中将docInfo定义为Map
。 这可能会奏效,但我目前无法放弃。 如果你没有一个根对象,你可以使用一个Map 作为你的根对象并从那里使用它。 该地图可以包含嵌套json对象的其他地图。 Assuming you have a root object that you are reading the result into, you could define docInfo as a Ma ...