小编S.P*_*.P.的帖子

如何从ContainerRequestContext获取数据来构建DTO对象

我是春季和球衣的新人。我正在尝试构建一个过滤器来检查请求是否具有正确的参数。这是我要检查的 json 部分:

"request":{
        "application":"1 Android Mobile",
        "version":1
    }
Run Code Online (Sandbox Code Playgroud)

数据元素是我的 VersionDTO 的一部分:

public class VersionDTO {
    int version;
    String application;

    public String getApplication() {
        return application;
    }

    public void setApplication(String application) {
        this.application = application;
    }

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

}
Run Code Online (Sandbox Code Playgroud)

这是我的过滤器的代码:

    @Override
    public void filter(ContainerRequestContext requestContext) throws FilterException {

        if (isSecureURL(requestContext.getUriInfo().getPath())){}{
            try {

                versionFilterService.setVersionDTO(//here is where I want to pass the VersionDTO object with the data of …
Run Code Online (Sandbox Code Playgroud)

jersey filter spring-boot

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

如何在动态视图中仅选择一个复选框

我有一个动态添加两行textView和一个CheckBox的行的屏幕.我的问题是我只希望用户可以检查一个,其他人必须取消选中.如果用户按下另一个复选框,请启用此选项并禁用所有其他复选框.我测试了一些东西,但我没有得到我想要的功能.

我无法将配置从复选框更改为radioButton,我必须使用我正在使用的方法:

private selected_position = -1;

protected void addGreetingToListView(final GreetingListJson greetings) {
        View row = inflater.inflate(R.layout.main_greetings_settings_row, greetingListView, false);
        row.setTag(greetings);

        playButton = (ToggleButton) row.findViewById(R.id.detail_play_greeting);            
        TextView greetingName = (TextView)row.findViewById(R.id.greetingTitle);
        greetingName.setDuplicateParentStateEnabled(true);
        TextView greetingDescription = (TextView)row.findViewById(R.id.greetingDescription);
        greetingDescription.setDuplicateParentStateEnabled(true);

        checkBox = (CheckBox) row.findViewById(R.id.checkBox_greeting_list);
        checkBox.setTag(greetings);


        checkBox.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick (View view) {

                if (((CheckBox) view).isChecked())
                {
                    selected_position= greetingListView.getChildCount();
                }
                else
                {
                    selected_position=-1;
                }           
            }

        });


                greetingName.setText(greetings.Name);
                greetingDescription.setText(greetings.Description);


            row.setOnClickListener(this);
            row.setOnLongClickListener(this);
            row.setFocusable(true);


            greetingListView.addView(row);

    }
Run Code Online (Sandbox Code Playgroud)

Checkbox的XML:

   <CheckBox
         android:id="@+id/checkBox_greeting_list"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentRight="true"
         android:layout_marginRight="15dp"
         android:layout_centerVertical="true"/> 
Run Code Online (Sandbox Code Playgroud)

checkbox android checkboxlist

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

如何获取grails中一列的所有数据?

我是grails的新手,我正在努力寻找解决方案,但我在这里没有发现任何问题......

我想做的是,我的域名中有这个标签:

    String platform
    String appVersion
    String name
    String id
Run Code Online (Sandbox Code Playgroud)

我怎样才能获得appVersion列中存储的所有数据?

grails grails-orm hibernate-criteria

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

如何用这样的数字拆分字符串|(12)|(23)

我有这个字符串

String numbers = "123;234;345;"
Run Code Online (Sandbox Code Playgroud)

我需要将它转换为新的字符串,如下所示:

String result= "|(123)|(234)|(345)"
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用这些numbers.split("\(");但是没有用,我找不到任何如何做的例子.

提前致谢,

java string split

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

我无法在运行时权限中显示 Manifest.permission.CALL_PHONE

我正在我的应用程序中实现运行时权限,但我无法显示 CALL_PHONE 的权限。我需要显示两个权限,read_contact 和 call_phone。我可以完美地显示 read_contact 但不能显示 call_phone 权限。

我正在使用 AVD 模拟器来测试它。

一些帮助将不胜感激!

这是我的代码:

      callPesmission.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                requestCallPhonePermission();
            }
        });

        contactPesmission.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                requestContactsPermission();
            }
        });


 private void requestContactsPermission() {
        String locationPermission = Manifest.permission.READ_CONTACTS;
        int hasPermission = ContextCompat.checkSelfPermission(getActivity(), locationPermission);
        String[] permissions = new String[] { locationPermission };
        if (hasPermission != PackageManager.PERMISSION_GRANTED) {
            requestPermissions(permissions, REQUEST_CONTACTS);
        } else {
            Toast.makeText(getActivity(), "We already have persmission", Toast.LENGTH_SHORT).show();
        }
    }

    private void requestCallPhonePermission() …
Run Code Online (Sandbox Code Playgroud)

permissions android

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

Null EntityManager使用@PersistenceContext

我正在尝试使用springboot的简单编码,使用entitymanager中的@PersistenceContext,在mysql中创建一个对象,但我得到的是我的entitymanager对象为null并且不确定原因,因为正在使用的方法entitymanager有@transaction注释.

提前致谢!

这是我调用插入数据的方法的代码:

import org.hibernate.service.spi.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
public class VehicleService implements IVehicleService {

    @Autowired
    IFileService fileService;

    @Transactional
    public void addVehicle(Vehicle vehicle) throws ServiceException{
        Vehicle vehicleNew = new Vehicle();
        vehicleNew.setName(vehicle.getName());
        vehicleNew.setType(vehicle.getType());
        vehicleNew.setEnrollment(vehicle.getEnrollment());
        try{
            fileService.createVehicle(vehicle);
        }catch(Exception e){

        }
    }   
}

import org.hibernate.service.spi.ServiceException;
import org.springframework.transaction.annotation.Transactional;

public interface IFileService {

    @Transactional
    void createVehicle(Vehicle vehicle) throws ServiceException;

}
Run Code Online (Sandbox Code Playgroud)

这是我调用entitymanager的地方,并且始终为null:

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Component;

@Component
public class FileService implements IFileService{

    @PersistenceContext
    protected EntityManager entityManager;

     public void createVehicle(Vehicle vehicle) { …
Run Code Online (Sandbox Code Playgroud)

java mysql entitymanager spring-transactions

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

找不到用于处理Intent com.android.camera.action.CROP的活动

我正在尝试从我的应用程序中制作图片。我可以启动相机并拍照,但是完成拍照后我的应用程序崩溃。我在屏幕上看到我的Galery已停止,这是我的日志中的错误:

我试图找到一些东西,但是对我有帮助。

提前致谢

FATAL EXCEPTION: main
                                                   android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.camera.action.CROP dat=file:///data/data/com.android.gallery3d/files/crop-temp (has extras) }
                                                       at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628)
                                                       at android.app.Instrumentation.execStartActivity(Instrumentation.java:1423)
                                                       at android.app.Activity.startActivityForResult(Activity.java:3388)
                                                       at android.app.Activity.startActivityForResult(Activity.java:3349)
                                                       at com.android.camera.actor.PhotoActor.doAttach(PhotoActor.java:1125)
                                                       at com.android.camera.actor.PhotoActor.access$500(PhotoActor.java:62)
                                                       at com.android.camera.actor.PhotoActor$2.onClick(PhotoActor.java:210)
                                                       at android.view.View.performClick(View.java:4209)
                                                       at android.view.View$PerformClick.run(View.java:17431)
                                                       at android.os.Handler.handleCallback(Handler.java:725)
                                                       at android.os.Handler.dispatchMessage(Handler.java:92)
                                                       at android.os.Looper.loop(Looper.java:153)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5297)
                                                       at java.lang.reflect.Method.invokeNative(Native Method)
                                                       at java.lang.reflect.Method.invoke(Method.java:511)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
                                                       at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

@Override
    public void onButton1Click(int ref) {
        try {
            currentRef = ref;
            Intent mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

            Uri fileUri = FileProvider.getUriForFile(getActivity(), BuildConfig.APPLICATION_ID + …
Run Code Online (Sandbox Code Playgroud)

android android-camera android-camera-intent

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