我有字节数组,由十六进制值组成 CA ,FA,21,33
但我想将它们JList列为单个元素CAFA2133.为了在JList中列出它们,我想我需要将其转换为string.那么任何推荐?
我试图根据他们的Locale获取货币的符号.但它没有返回符号,而是返回代码.我有一个片段:
import java.util.Currency;
import java.util.Locale;
public class CurrencyFormat
{
public void displayCurrencySymbols()
{
Currency currency = Currency.getInstance(Locale.US);
System.out.println("United States: " + currency.getSymbol());
}
public static void main(String[] args)
{
new CurrencyFormat().displayCurrencySymbols();
}
}
Run Code Online (Sandbox Code Playgroud)
对于Locale.US,它给出符号$但是如果我替换
Currency currency = Currency.getInstance(Locale.US);
Run Code Online (Sandbox Code Playgroud)
同
Currency currency = Currency.getInstance(Locale.GERMANY);
Run Code Online (Sandbox Code Playgroud)
然后代替符号,它给出了国家代码.为什么这样以及我们如何获得符号?
编辑:在看了一些答案后,我想清楚设置一些特定的默认本地不是解决方案,因为我需要一次显示所有可用的符号.
例如
Locale.setDefault(Locale.UK);
Run Code Online (Sandbox Code Playgroud)
将给我欧元符号,但对于doller它将给代码而不是doller sign($).
我试图登录的几个值onBeginRequest()的RequestCycle()在检票口.但是这些值未记录在调试文件中.我将值放在MDC中RequestCycleListeners().
以下是代码:
getRequestCycleListeners().add(new AbstractRequestCycleListener()
{
public void onBeginRequest(RequestCycle cycle)
{
if( cycle.getRequest().getContainerRequest() instanceof HttpServletRequest )
{
HttpServletRequest containerRequest =
(HttpServletRequest)cycle.getRequest().getContainerRequest();
MDC.put("serverName", containerRequest.getServerName());
MDC.put("sessionId", containerRequest.getSession().getId());
LOGGER.debug("logging from RequestCycleListeners() !!!");
WebClientInfo webClientInfo = new WebClientInfo(RequestCycle.get());
System.out.println(webClientInfo.getUserAgent());
System.out.println("webClientInfo.getProperties().getBrowserVersionMajor() " +containerRequest.getRemoteAddr());
}
Run Code Online (Sandbox Code Playgroud)
};
我期待'serverName','sessionId'被记录在调试文件中.
我listener在扩展的类中添加了这个WebApplication.
我使用的DEBUG appender是log4j.xml ,如下所示:
<appender name="DEBUG" class="org.apache.log4j.rolling.RollingFileAppender">
<param name="Append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ISO8601} %t %5p] %m -- %X{serverName} -- %X{sessionId} -- %X{portNumber}%n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param …Run Code Online (Sandbox Code Playgroud) 我需要使用java POJO类映射JSON数组对象.我写了这样的代码:
// execute the client with get method
InputStream inputStream = getMethod.getResponseBodyAsStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
ObjectMapper objectMapper = new ObjectMapper();
JsonFactory jsonFactory = new JsonFactory();
List<OwnerDetail> owners = new ArrayList<>();
JsonParser jsonParser = jsonFactory.createJsonParser(inputStream);
if (jsonParser.nextToken() != null && jsonParser.)
{ // end-of-input
owners = objectMapper.readValue(bufferedReader, TypeFactory.defaultInstance().constructCollectionType(List.class, OwnerDetail.class));
}
Run Code Online (Sandbox Code Playgroud)
以上块给出了以下错误:
com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
at [Source: java.io.BufferedReader@5e66c5fc; line: 1, column: 1]
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:164)
at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3029)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2971)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2128)
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.谢谢.
我有一个查询应该根据列值在asc或desc中排序结果.
例如
如果类型管理员的员工通过join_date存在那么订单,bith_date ASC如果员工是开发人员那么由join_date,birth_date DESC订购.
我想实现类似下面的东西,但无法实现.
ORDER BY CASE WHEN employee_type = 'm'
THEN joining_date, birth_date ASC;
WHEN employee_type = 'd'
THEN joining_date, birth_date DESC;
Run Code Online (Sandbox Code Playgroud) 我有一个Jtable,我必须在其中显示一些大数据.我不能增加单元格的大小所以我需要在表格的每个单元格中添加一个滚动条,通过它我可以滚动单元格的文本.
我试图添加自定义单元格渲染器
private class ExtendedTableCellEditor extends AbstractCellEditor implements TableCellEditor
{
JLabel area = new JLabel();
String text;
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int rowIndex, int vColIndex)
{
area.setText(text);
return new JScrollPane(area);
}
public Object getCellEditorValue()
{
return text;
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我可以在单元格上看到滚动条,但无法单击并滚动它们.
对这个问题的任何建议都会很棒.提前致谢.
我试图使用VIEWas 在表中插入一行
INSERT INTO FIELDI18N(LANGUAGE_ID) VALUES (1);
Run Code Online (Sandbox Code Playgroud)
但它给了我以下错误:
Error starting at line 5 in command:
INSERT INTO FIELDI18N(LANGUAGE_ID) VALUES (1)
Error at Command Line:5 Column:22
Error report:
SQL Error: ORA-01733: virtual column not allowed here
01733. 00000 - "virtual column not allowed here"
*Cause:
*Action:
Run Code Online (Sandbox Code Playgroud)
任何线索?
添加了视图定义:
CREATE OR REPLACE VIEW FIELDI18N("FIELDID", "NAME", "TYPE", "DESCRIPTION", "LANGUAGE_ID")
AS
(SELECT field.fieldid,
field.type,
NVL(i18n.name, field.name) name,
NVL(i18n.description, field.description) description,
i18n.language_id
FROM fields field
JOIN i18n_fields i18n
ON (field.fieldid = i18n.fieldid)
);
Run Code Online (Sandbox Code Playgroud) 我试图通过log4j发送错误电子邮件.通过使用以下appender:
<appender name="ERROR_MAIL" class="org.apache.log4j.net.SMTPAppender">
<param name="SMTPUsername" value="xxxxxx@gmail.com" />
<param name="SMTPPassword" value="**********" />
<param name="To" value="test@gmail.com"/>
<param name="From" value="xxxxxx@gmail.com"/>
<param name="Subject" value="Newyse Error "/>
<param name="SMTPHost" value="smtp.gmail.com"/>
<param name="SMTPPort" value="25" />
<param name="BufferSize" value="10"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ISO8601} %t %5p %c:$L]"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="ERROR"/>
<param name="LevelMax" value="FATAL"/>
</filter>
</appender>
Run Code Online (Sandbox Code Playgroud)
但我得到以下例外
com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. wr9sm43519864pbc.7 - gsmtp
Run Code Online (Sandbox Code Playgroud)
从其他几个问题我明白我需要添加以下属性 smtpAppender
props.put("mail.smtp.starttls.enable", "true");
Run Code Online (Sandbox Code Playgroud)
那么我们如何将它添加到现有的SMTPAppender?
我创建了一个包含大量数据的xml.现在我试图将生成的xml写入文件.
宣言:
prodFeed_file UTL_FILE.FILE_TYPE;
prodFeed_file := UTL_FILE.FOPEN ('CSV_DIR', 'feed.xml', 'w', 32767);
Run Code Online (Sandbox Code Playgroud)
写入文件:
UTL_FILE.PUT_LINE(prodFeed_file,l_xmltype.getClobVal);
UTL_FILE.FCLOSE(prodFeed_file);
Run Code Online (Sandbox Code Playgroud)
如果l_xmltype.getClobVal返回限制记录然后它是工作文件但如果l_xmltype.getClobVal超过大小(几乎35 KB)它会给出一个错误:
ORA-06502: PL/SQL: numeric or value error
我是新手C++ programming,我在阅读C++有关复制构造函数时遇到了疑问.当我们将类的对象传递给外部函数作为pass by value时,为什么复制构造函数会调用.请按以下方式查看我的代码.
#include "stdafx.h"
#include <iostream>
#include <conio.h>
using namespace std;
class Line
{
public:
int getLength( void );
Line( int len ); // simple constructor
Line( const Line &obj); // copy constructor
~Line(); // destructor
private:
int *ptr;
};
// Member functions definitions including constructor
Line::Line(int len)
{
cout << "Normal constructor allocating ptr" << endl;
ptr = new int;
*ptr = len;
}
Line::Line(const Line &obj)
{
cout << "Copy constructor allocating …Run Code Online (Sandbox Code Playgroud) 我正在使用Spring MVC 3.0框架开发应用程序,我有以下要求,
一个jsp页面中有多个表单.我正在使用ajax提交每个表单.但提交后,每个表格都会转到不同的控制器.在控制器中,如果我需要将验证结果发送回jsp页面,我将验证输入数据.现在我将错误存储到一个单独的列表中,并通过json响应发送回jsp.我不确定是否使用bindingResult.getAllErrors()或bindingResult.getFieldErrors()获取控制器中的错误列表.两者有什么区别?