小编Dra*_*ken的帖子

使用apache poi将列设为只读

我正在使用apache-poi生成excel文件.我需要将第4列设为只读,其余2列将由用户编辑.

我正在用它XSSFCellStyle来实现这个目标,但它对我不起作用.

整个代码是:

Map<String, XSSFCellStyle> styles = new HashMap<String, XSSFCellStyle>();

XSSFCellStyle style5 = wb.createCellStyle();
XSSFFont headerFont = wb.createFont();
headerFont.setBold(true);
style5.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
style5.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
style5.setFont(headerFont);
style5.setLocked(true); // this line does not get executed.
styles.put("header", style5);
Run Code Online (Sandbox Code Playgroud)

java excel apache-poi

6
推荐指数
1
解决办法
1万
查看次数

org.hibernate.exception.JDBCConnectionException:无法在MySQL中打开连接异常

我已经在我的本地机器上设置了一个mysql实例,并将它与我在GAE上的java hibernate应用程序一起使用.这是完美的工作,但从下午开始给我下面给出的错误.请帮我弄清楚如何解决这个问题.我被困住了,没有任何数据库事务就无法继续执行代码.谢谢!

org.hibernate.exception.JDBCConnectionException: Could not open connection
    at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:131)
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
    at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:304)
    at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169)
    at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.extractPhysicalConnection(ConnectionProxyHandler.java:82)
    at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.continueInvocation(ConnectionProxyHandler.java:138)
    at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
    at com.sun.proxy.$Proxy47.prepareStatement(Unknown Source)
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:147)
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:166)
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:145)
    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1711)
    at org.hibernate.loader.Loader.doQuery(Loader.java:828)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)
    at org.hibernate.loader.Loader.doList(Loader.java:2438)
    at org.hibernate.loader.Loader.doList(Loader.java:2424)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2254)
    at org.hibernate.loader.Loader.list(Loader.java:2249)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
    at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195)
    at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1248)
    at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
    at com.bullbeardevice.dao.impl.UserManagementDAOImpl.getUserRegistrationList(UserManagementDAOImpl.java:39)
    at com.bullbeardevice.service.impl.UserManagementServiceImpl.checkUserAlreadyRegistered(UserManagementServiceImpl.java:111)
    at com.bullbeardevice.controller.user.UserManagementController.registerUser(UserManagementController.java:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
    at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
    at …
Run Code Online (Sandbox Code Playgroud)

java mysql google-app-engine hibernate spring-mvc

6
推荐指数
1
解决办法
5万
查看次数

我可以使用Fitbit Api来获取Fitbit的加速度数据吗?

我正在尝试使用Fitbit的数据来抓住我的手部动作.

然后我在这里找到Fitbit Api:https://wiki.fitbit.com/display/API/Fitbit+Resource+Access+API

在收集资源部分,我似乎只能获得一些数据,如身体测量,体重,近期活动,朋友等.

所以,我的问题是,Fitbit是否提供任何API来帮助我获取实时加速度计数据和陀螺仪数据?

java api sensor accelerometer fitbit

6
推荐指数
1
解决办法
944
查看次数

标题或实体中的 Hateoas 链接

我已经看到了添加 JSON REST Hateoas 的两种主要方法,但我不确定哪种方法更标准或每种方法的优缺点。

我看到的典型方法(Atom Links)是返回的实体附加一个名为 或 的links字段_links。该字段是一个rel=<rel>href=<href>对的数组。

但我也看到(链接标头)链接放入名为“Link”的标头值中。该链接是一个格式为 的集合<hef>; rel=<rel>

另外,我注意到在 JAX-RS 中似乎没有添加具有完全限定的 href 的 Atom 链接,只有路径。我所说的完全合格是指包括计划和权威。在使用 Atom Links for HATEOAS 时,为 href 提供完整的 URI 是否被视为不好的做法?

rest json jax-rs hateoas

6
推荐指数
1
解决办法
3465
查看次数

SOAPExceptionImpl:无效的内容类型:文本/html。这是错误消息而不是 SOAP 响应吗?

我需要有关调用 Web 服务的帮助。我org.springframework.ws.client用来调用WS,代码如下:

Response response = (Response) getWebServiceTemplate().marshalSendAndReceive(
                "http://ip:port/DefaultRequestListener?workflow=WsdlCPF&soapAction=Import",
                request,
                new SoapActionCallback("http://ip:port/DefaultRequestListener?workflow=WsdlCPF&soapAction=Import"));
Run Code Online (Sandbox Code Playgroud)

此外,我可以http://ip:port/DefaultRequestListener?workflow=WsdlCPF&soapAction=Import使用 SOAP UP调用 WS 并使用此链接(看起来很奇怪)接收响应。它工作正常。

从 IDE 运行代码后,我收到下一个堆栈跟踪:

Exception in thread "main" java.lang.IllegalStateException: Failed to execute CommandLineRunner
    at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:677)
    at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:693)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:322)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:969)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:958)
    at com.mayacomp.feeder.Application.main(Application.java:33)
Caused by: org.springframework.ws.soap.SoapMessageCreationException: Could not create message from InputStream: Invalid Content-Type:text/html. Is this an error message instead of a SOAP response?; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Invalid Content-Type:text/html. Is this an error message instead of a …
Run Code Online (Sandbox Code Playgroud)

java soap spring-ws

6
推荐指数
1
解决办法
3万
查看次数

在java中读取Excel工作表时出现NoSuchFieldError

我遵循了使用Apache POI XSSF构建工作簿的简单指南.按照相同的指南,我能够写一个Excel工作表,但是当试图从一个读取时,我收到代码后显示的错误.

码:

try {
    FileInputStream file = new FileInputStream(new File("howtodoinjava_demo.xlsx"));

    // Create Workbook instance holding reference to .xlsx file
    XSSFWorkbook workbook = new XSSFWorkbook(file);

    // Get first/desired sheet from the workbook
    XSSFSheet sheet = workbook.getSheetAt(0);

    // Iterate through each rows one by one
    Iterator<Row> rowIterator = sheet.iterator();
    while (rowIterator.hasNext()) {
        Row row = rowIterator.next();
        // For each row, iterate through all the columns
        Iterator<Cell> cellIterator = row.cellIterator();

        while (cellIterator.hasNext()) {
            Cell cell = cellIterator.next();
            // Check the cell …
Run Code Online (Sandbox Code Playgroud)

java xssf nosuchfieldexception

6
推荐指数
1
解决办法
2万
查看次数

使用javascript检测CSP违规

是否可以使用javascript检测内容安全策略违规?

我的CSP工作并发送其报告,我看到一些网址被注入,可能是浏览器插件.我想向用户显示一个提示,一些插件尝试修改页面.

我可以以某种方式检测与javascript的中止连接(当然它在CSP中列入白名单)?

javascript content-security-policy

6
推荐指数
1
解决办法
884
查看次数

源级别1.7不允许如何修复"<>"运算符

我使用的是JDK 1.8.0.当我将代码导入Eclipse时,我收到错误:

源级别1.7不允许使用"<>"运算符

例:

List<String[]> errors = new ArrayList<>();
Run Code Online (Sandbox Code Playgroud)

我正在使用Eclipse Kepler.

java eclipse

6
推荐指数
4
解决办法
1万
查看次数

keras中的border_mode是什么意思?

我很困惑使用什么,有效的,相同或完整的。我也不知道它做什么。我在文档中找不到它。而且border_mode对于MaxPooling2D我来说,分层是没有意义的。(不过,对于卷积层来说,这对我来说确实有意义)。

theano keras

6
推荐指数
1
解决办法
2919
查看次数

530 用户无法使用 FTPSClient 登录

我们尝试使用与标准 FTP 客户端中相同的凭据来访问我们的 FTPS 服务器之一。但是,当使用 Java 类时,FTPSClient我们收到错误消息:

530 用户无法登录。

没有别的。到目前为止,我们有以下代码(示例中的简化):

public final class FTPSExample {

    public static final void main(String[] args) {
        boolean error = false;
        String server, username, password;
        String protocol = "TLS";    // SSL/TLS
        FTPSClient ftps;


        server = "A_SERVER";
        username = /*server + "|" + */"A_USER";
        password = "A_PASS";

        ftps = new FTPSClient(protocol);
        ftps.setTrustManager(TrustManagerUtils.getAcceptAllTrustManager());

        ftps.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));

        try {
            int reply;

            ftps.connect(server, 21);
            System.out.println("Connected to " + server + ".");

            reply = ftps.getReplyCode();

            if (!FTPReply.isPositiveCompletion(reply)) { …
Run Code Online (Sandbox Code Playgroud)

java ftp ssl

6
推荐指数
1
解决办法
8364
查看次数