小编Mud*_*zad的帖子

从Android的Jersey Resftul webservice传递和接收JSON对象

场景:将json对象中的用户名和密码传递给restful webservice并获得一个json对象.是的,我知道,它很简单,但我不能让它发挥作用.

几天来我一直在尝试这个.到目前为止,我试过这个:

我宁静的网络服务代码

@POST
    @Path("/testJson")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public JSONObject testJson(JSONObject inputJsonObj) throws Exception {

        JSONObject myjson = new JSONObject();

        if(inputJsonObj != null){

        System.out.println("=================================");
        System.out.println("JSON object = " + inputJsonObj.toString());
        System.out.println("=================================");

        }
        else{
            System.out.println("JSON is NULL");

        }

        myjson.put("success", "1");

        System.out.println(myjson.toString());

//        return "string returned";
        return myjson;
    }
Run Code Online (Sandbox Code Playgroud)

在我的android acivity中,代码是

// POST request to <service>/SaveVehicle
        HttpPost request = new HttpPost(myURL);
        request.setHeader("Accept", "application/json");
        request.setHeader("Content-type", "application/json");
        request.setHeader("user-agent", "Yoda");


        try {
            // Build JSON string
            // JSONStringer vehicle = new JSONStringer().object()
            // .key("getItInputTO").object().key("zipCode").value("90505")
            // …
Run Code Online (Sandbox Code Playgroud)

java rest android json web-services

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

Primefaces TabView活动索引无法正常工作

我已经完全更改了代码。但是活动索引仍然显示出问题。有时它被调用,而有时它不被调用。以下xhtml代码有什么问题?

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui" >
    <h:head>
        <title>Admin Panel</title>

        <style type="text/css">
            .ui-accordion .ui-accordion-content{
                background-color: #eedae3;
            }
            .ui-accordion .ui-accordion-header {
                height: 30px;
                background-color: #e74f54;
            } 
            .ui-tabs .ui-tabs-nav li{
                background-color: #6f97df;
                height: 35px;
            }
            .datatable{
                background-color: #eedae3;
            }
        </style>

    </h:head>
    <h:body>  
        <p:tabView id="tabView" activeIndex="#{profileInfoManagedBean.myCurrentTab}" >
            <p:ajax event="tabChange" listener="#{profileInfoManagedBean.tabIsChangedKana}" />


            <p:tab id="locationInfoTab" title="Location Info">

                <h:form id="form1">
                    <p:growl showDetail="true" />

                    <p:panel header="New Country">  
                        <h:panelGrid columns="3" cellpadding="5" cellspacing="5">

                            <p:column>
                                <h:outputLabel for="country" …
Run Code Online (Sandbox Code Playgroud)

jsf primefaces tabview

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

登录后如何重定向?

我将用户名和密码绑定到支持托管bean.在支持bean中,当我用DB检查用户名和密码时,我想将页面重定向login.xhtmlhome.xhtml.我怎样才能做到这一点?

jsf redirect managed-bean

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

如何使用 Junit 5 在 Spring boot 2.1.0.M4 中使用 @DataJpaTest 测试 Spring CrudRepository

我无法使用带有 Junit5 的 spring boot 2.1.0.M4 和@DataJpaTest. 我正在使用以下 spring crud 存储库界面。

@Repository
public interface DestinationRepository extends CrudRepository<Destination, String> {

    Optional<Destination> findCityCode(String code, String cityIsolci);

}
Run Code Online (Sandbox Code Playgroud)

这是我的单元测试课

package com.test.repository;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.test.Destination;

import java.util.Optional;

import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@DataJpaTest
// @ExtendWith(SpringExtension.class)
public class DestinationRepositoryTest {

    @Autowired
    private TestEntityManager entityManager;

    @Autowired
    private DestinationRepository destinationRepository;

    @Test
    public void whenfindByCodeAndCityIsolciThenReturnDestination() throws Exception …
Run Code Online (Sandbox Code Playgroud)

spring spring-data-jpa spring-boot junit5

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