小编pao*_*988的帖子

用于登录的身份验证过滤器和servlet

我有一个用于登录的过滤器.它在"用户名"和"密码"字段上执行文本检查.当且仅当文本检查正确完成时,请求才会进入Servlet.后者执行必须与数据库交互的控件.这个链条是否正确?

authentication servlets login-control servlet-filters

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

Android TableLayout连续不同列的宽度

我正在尝试做我的第一个复杂的GUI,但现在我无法解决这个问题.

在此输入图像描述

前两行的第一列只需要包含标签,而前两行的第二列必须占用剩余空间.

在这张快照中,我注意到的问题是第一列比我想要的要大.

这是实现该布局的一段代码.

...
...

<TableLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:layout_margin="5dp"
        android:background="@drawable/linear_layout_background"
        android:stretchColumns="*"
        android:shrinkColumns="*">

       <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="20dp" >

        <TextView
            android:id="@+id/textViewPlateValueLabel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/plateValue"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/productID"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/back"
            android:ems="5"
            android:text="@string/blank"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        </TableRow>

       <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="20dp" >

           <TextView
            android:id="@+id/ztlLabel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/ztl"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/ztlShow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/back"
            android:text="@string/blank"
            android:textAppearance="?android:attr/textAppearanceLarge" />

       </TableRow>

       <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:gravity="center" >

           <TextView
            android:id="@+id/isAllowed"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/blank"
            android:background="@drawable/back"
            android:textAppearance="?android:attr/textAppearanceLarge" />

            </TableRow>

   </TableLayout>
   ...
   ...
Run Code Online (Sandbox Code Playgroud)

另外,由于它们确实不切实际,我想问你一些关于最佳使用方法的建议.

android android-layout android-tablelayout

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

Python在拆分中跳过连续分隔符

我需要用“\”分隔符分割一个字符串。但我必须跳过连续出现的情况。更准确地说,对于我的目标,“//sensor1”需要读作“/sensor1”。

import re
a = "root/master/sensors//sensor1/value"
re.split("/+", a)
Run Code Online (Sandbox Code Playgroud)

所以我需要获得:

['root', 'master', 'sensors//sensor1', 'value']
Run Code Online (Sandbox Code Playgroud)

我试过那个代码,但也许我在正则表达式中犯了错误。

python regex split

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

GCM不会在Android 4下面收到消息

我的Gcm应用程序收到来自GCM for Android 4及更高版本的精彩信息.但在我的应用程序下面没有收到消息.

这是GcmBroadcastReceiver:

public class GcmBroadcastReceiver extends WakefulBroadcastReceiver 
{

    @Override
    public void onReceive(Context context, Intent intent) 
        {
            // TODO Auto-generated method stub

            ComponentName comp = new ComponentName(context.getPackageName(), GCMIntentService.class.getName());
            Log.i("GCM BROADCAST", "Begin Broadcast");

            startWakefulService(context, intent.setComponent(comp));

            setResultCode(Activity.RESULT_OK);
        }
}
Run Code Online (Sandbox Code Playgroud)

这是意图:

public class GCMIntentService extends IntentService 
{
    public static final String TAG = "GcmIntentService";
    public static final int NOTIFICATION_ID = 1;

    public GCMIntentService()
        {
            super(Constant.SENDER_ID);
        }

/* (non-Javadoc)
 * @see android.app.IntentService#onHandleIntent(android.content.Intent)
 */
@Override
protected void onHandleIntent(Intent intent)
    {
        // TODO Auto-generated …
Run Code Online (Sandbox Code Playgroud)

android broadcastreceiver android-intent google-cloud-messaging google-play-services

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

崩溃后重新启动辅助功能服务

在我的应用程序中有一个Service和一个AccessibilityService.现在Service受可访问性服务的约束,以便接收信息.

我会Service定期检查是否AccessibilityService已启用,如果未启用,则会向用户发送通知,表明它必须启用它.

启用后,即可AccessibilityService开始工作.首先,它绑定到我Service,之后,它开始发送信息.

问题是如果AccessibilityService崩溃了.它仍然启用但没有正在运行的实例.所以我Service发现它已启用,但实际上AccessibilityService它没有运行.

怎么检查 AccessibilityService

public boolean checkAccesibilityService()
    {
        int accessibilityEnabled = 0;
        boolean accessibilityFound = false;
        try {
            accessibilityEnabled = Settings.Secure.getInt(
                    mContext.getApplicationContext().getContentResolver(),
                    android.provider.Settings.Secure.ACCESSIBILITY_ENABLED);
            //Log.v(TAG, "accessibilityEnabled = " + accessibilityEnabled);
        } catch (Settings.SettingNotFoundException e) {
            Log.e(TAG, "Error finding setting, default accessibility to not found: "
                    + e.getMessage());
        }

        if (accessibilityEnabled == 1) {
            //Log.v(TAG, "***ACCESSIBILIY IS ENABLED*** -----------------");
            String …
Run Code Online (Sandbox Code Playgroud)

service binding android accessibilityservice

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

Jsp的URL映射

我想为我的网页做一个映射.我在web.XML中完成的一种像Servlet Mapping这样的映射,不一定是相同的代码或程序,但结果相同.换句话说,我的目标是隐藏我的网页部署.可能吗?

xml jsp web-applications url-mapping

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

正则表达式Java Merge Pattern

我有这三个正则表达式.他们单独工作,但我想将它们合并为一个单一的模式.

regex1 = [0-9]{16}
regex2 = [0-9]{4}[-][0-9]{4}[-][0-9]{4}[-][0-9]{4}
regex3 = [0-9]{4}[ ][0-9]{4}[ ][0-9]{4}[ ][0-9]{4}
Run Code Online (Sandbox Code Playgroud)

我用这个方法:

Pattern.compile(regex);
Run Code Online (Sandbox Code Playgroud)

合并它们的正则表达式字符串是什么?

java regex

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