我有一个BigDecimal对象,我想将其转换为字符串.问题是我的值得分,我得到一个巨大的数字(长度),我只需要字符串中的原始数字,例如:for
BigDecimal bd = new BigDecimal(10.0001)
System.out.println(bd.toString());
System.out.println(bd.toPlainString());
Run Code Online (Sandbox Code Playgroud)
输出是:
10.000099999999999766941982670687139034271240234375
10.000099999999999766941982670687139034271240234375
Run Code Online (Sandbox Code Playgroud)
我需要输出正好是10.0001字符串中的数字
我在开头有一行空格,例如"Hello world".我想将此行插入文件中的特定行.例如,将"hello world"插入下一个文件
hello
world
Run Code Online (Sandbox Code Playgroud)
结果:
hello
hello world
world
Run Code Online (Sandbox Code Playgroud)
我正在使用这个sed脚本:
sed -i "${line} i ${text}" $file
Run Code Online (Sandbox Code Playgroud)
问题是我得到的新线路没有空格:
hello
hello world
world
Run Code Online (Sandbox Code Playgroud) 有没有办法让grep的每个结果后跟换行符,例如grep的结果是:
1
2
3
Run Code Online (Sandbox Code Playgroud)
我需要它:
1
2
3
Run Code Online (Sandbox Code Playgroud) 我正在使用Wicket 1.5构建Web应用程序.我需要确定当前登录的用户是管理员还是普通用户,并为每个用户显示不同的页面.
我的代码:
public class HomePage extends WebApplication {
private boolean flag = false;
@Override
protected void init(){do things}
@Override
public Session newSession(Request request, Response response) {
... some calculation ...
return new HomePageWebSession(request);
}
@Override
public Class<? extends WebPage> getHomePage(){
if(flag){
return Admin.class
} else return User.class
}
}
Run Code Online (Sandbox Code Playgroud)
问题是getHomepage之前调用的newSession,我使用newSession来确定用户是否是Admin并初始化标志.另外我看到getHomePage之前newSession被调用多次.为什么getHomePage称为倍数,为什么getHomePage之前被称为newSession?
谢谢你的帮助
嗨,我正在寻找一个awk,可以找到两个模式,并将它们之间的数据打印到文件,只有在中间有中间的第三个模式.例如:
Start
1
2
middle
3
End
Start
1
2
End
And the output will be:
Start
1
2
middle
3
End
Run Code Online (Sandbox Code Playgroud)
我在web awk'/ patterns1 /,/ patterns2 /'path> text.txt中找到了但我只需输出中间的第三个模式.
我ReloadableResourceBundleMessageSource在我的web项目中使用,并且我将类注入到servlet中,问题是我想使用Spring注释注入类但它似乎不起作用?我的代码是:
my.xml
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>classpath:myList</value>
</list>
</property>
<property name="cacheSeconds" value="1"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
myServletClass.java
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("my.xml");
String message = applicationContext.getMessage(message, null, "Default
", null);
}
Run Code Online (Sandbox Code Playgroud)
如何注入ReloadableResourceBundleMessageSource使用注释?
我正在使用HTML和Wicket编写Web应用程序.
在我的HTML页面中,我有一个小的警报脚本,我需要wicket将一个值插入警报的消息.我的代码是:
<script>
function version(){
alert(<sub wicket:id="version">);
}
</script>
<img class="logo" src="images/logo.png" alt="" width="68" height="21" onclick="version()"/>
Run Code Online (Sandbox Code Playgroud)
add(new Label("version","1.0.0");
Run Code Online (Sandbox Code Playgroud)
但这不起作用.
linux ×3
java ×2
sh ×2
shell ×2
unix ×2
annotations ×1
awk ×1
bash ×1
bigdecimal ×1
dynamic ×1
html ×1
javascript ×1
sed ×1
servlets ×1
session ×1
spring ×1
string ×1
wicket ×1
wicket-1.5 ×1