为什么第一个例子打印出错误的结果?
perl -le 'print $x = 100*1.15 % 5'
4
perl -le 'print $x = 1000*1.15 % 5'
0
Run Code Online (Sandbox Code Playgroud) 在我的Web应用程序上,我正在加载一个页面,该页面可以在表格中加载多达8000行或更多行,每行都有自己的下拉列表.第一个过程被证明是非常低效的,但我被要求这样做.加载行的代码如下:
<tbody>
<% var i = 0;
foreach (var row in Model)
{
var comp = "ok";
if (row.LidExpected != (string.IsNullOrEmpty(row.LidObtained) ? null : row.LidObtained) || row.QuantityExpected != row.QuantityObtained)
{
comp = "ko";
}
%>
<tr class="child_row <%= comp %>">
<input type="hidden" name="Goods.index" value="<%= i %>" />
<td class="field <%= InventoryGoods.Metadata.Gid.CssClass %>">
<%-- <%= Html.Encode(row.Gid) %>--%>
<%--http://tecnicos.urbanos.com/Goods/Details/... --%>
<%= Html.ActionLink(row.Gid, "Details", "Goods", new {id = row.Gid}, null) %>
<%= Html.Hidden(String.Format("Record[{0}].Gid", i), row.Gid) %>
</td>
<td class="field <%= InventoryGoods.Metadata.LidExpected.CssClass %>">
<%= …Run Code Online (Sandbox Code Playgroud) 我有一个类似{A,B,C,D,E,F,G,H}的数组.我希望能够选择索引或条目并重新排序数组.所以说如果我有一个功能
reorder('C');
Run Code Online (Sandbox Code Playgroud)
它会从C开始返回数组,在此索引添加到结尾之前有任何内容,所以这个例子会给出
{C,D,E,F,G,H,A,B}
Run Code Online (Sandbox Code Playgroud)
有功能已经这样做了吗?
谢谢
编辑:我最后用过这个
$key = array_search($imgToShow, $imgList);
$sliceEnd = array_slice($imgList, 0, $key);
$sliceStart = array_slice($imgList, count($sliceEnd));
$array = array_merge($sliceStart, $sliceEnd);
Run Code Online (Sandbox Code Playgroud) 我在Facelets上使用JSF2.
我<ui:param>在页面中定义了一个:
<ui:composition template="/WEB-INF/templates/ui.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
<ui:param name="title" value="OnAir WebDemo" />
...
</ui:composition>
Run Code Online (Sandbox Code Playgroud)
在ui.xhtml模板中我有:
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jstl/core"
>
<c:if test="#{not empty title}">
<h1>#{title}</h1>
</c:if>
</html>
Run Code Online (Sandbox Code Playgroud)
但是,<c:if test>似乎总是评估true,如果<ui:param>没有指定.如何更改代码,以便在未指定时<c:if test>实际评估?false<ui:param>
为什么Integer.toString()使用String.valueOf(int i)而不是直接使用Integer.toString(int i)被回调的静态方法来实现该方法String.valueOf(int i)?
更新:我正在使用Sun(Oracle现在)jdk 1.6.0_12
我一直在使用Scala中的包装类和导入包时遇到困惑.让我从一对简单的源文件开始:
package a
// Which of these imports should be used? They both seem to work.
//import a.b._
import b._
class A {
val fieldB = new B
}
Run Code Online (Sandbox Code Playgroud)
package a.b
class B
Run Code Online (Sandbox Code Playgroud)
使用scalac进行编译时无需投诉A.scala中的任何导入
尝试在REPL中加载这些文件的方式不同:
$ scala
Welcome to Scala version 2.8.0.r0-b20100714201327 (Java HotSpot(TM) Server VM, Java 1.6.0_20).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :l a/b/B.scala
Loading a/b/B.scala...
<console>:1: error: illegal start of definition
package a.b
^
defined class B …Run Code Online (Sandbox Code Playgroud) 我正在尝试将 war 文件从公司的 Nexus 存储库复制到特定位置。我按以下方式使用maven-dependency-plugin :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>copy-to-output</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.mycompany</groupId>
<artifactId>myproduct</artifactId>
<version>2.3.0</version>
<type>war</type>
<overWrite>false</overWrite>
</artifactItem>
</artifactItems>
<outputDirectory>${basedir}/src/main/output</outputDirectory>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
当我尝试使用<version>RELEASE</version>而不是特定版本(或根本没有版本)以获得最新的发行版本(虽然不是最佳实践,但在这种情况下它是安全的)时,问题就出现了 - 它不起作用。有什么想法吗?
您好我想将UNIX日期转换为正常日期(YYYY-MM-DD)
22222,0,0,0,14387
33333,0,0,0,14170
44444,0,0,0,14244
55555,0,0,0,14190
66666,0,0,0,14528
77777,0,0,0,14200
88888,0,0,0,0
99999,0,0,0,0
Run Code Online (Sandbox Code Playgroud)
这里第5列代表UNIX日期
我想转换成
22222,0,0,0,2009-05-23
Run Code Online (Sandbox Code Playgroud)
和类似的剩余行
有谁能够帮我
我在排序管理类中自动解析和手动依赖的方法时遇到了一些麻烦.
假设我有两个课程来计算价格:一个计算我将收取多少运费,另一个计算我将为整个订单收取多少费用.第二个使用第一个,以便将运费与整个订单价格相加.
这两个类都依赖于第三类,我将其称为ExchangeRate,它给出了我应该用于计算价格的汇率.
到目前为止,我们有这种依赖链:
OrderCalculator - > ShippingCalculator - > ExchangeRate
我正在使用Ninject来解决这些依赖关系,这一直在使用.现在我要求ExchangeRate类返回的速率将根据将在构造函数中提供的参数而变化(因为对象不能在没有这个的情况下工作,因此要使依赖项显式放置在构造函数上)来自用户输入.因此,我无法再自动解析我的依赖项.
每当我想要OrderCalculator或依赖于ExchangeRate的任何其他类时,我都不能要求Ninject容器解析它,因为我需要在构造函数中提供参数.
在这种情况下你有什么建议?
谢谢!
编辑:我们添加一些代码
这个对象链由WCF服务使用,我使用Ninject作为DI容器.
public class OrderCalculator : IOrderCalculator
{
private IExchangeRate _exchangeRate;
public OrderCalculator(IExchangeRate exchangeRate)
{
_exchangeRate = exchangeRate;
}
public decimal CalculateOrderTotal(Order newOrder)
{
var total = 0m;
foreach(var item in newOrder.Items)
{
total += item.Price * _exchangeRate.GetRate();
}
return total;
}
}
public class ExchangeRate : IExchangeRate
{
private RunTimeClass _runtimeValue;
public ExchangeRate(RunTimeClass runtimeValue)
{
_runtimeValue = runtimeValue;
}
public decimal GetRate()
{ … 我想知道为什么这个方法String.valueOf(int i)存在?我正在使用此方法转换int为String刚刚发现的Integer.toString(int i)方法.
在查看了这些方法的实现后,我看到第一个调用第二个方法.因此,String.valueOf(int i)除了直接打电话,我所有的呼叫都要多打一次电话Integer.toString(int i)