小编Rom*_*n C的帖子

小程序不显示任何内容

一个简单的问题可能不是那么简单的解决方案.我的代码应该在黑色背景上显示一个可以在屏幕上移动的三角形.只显示任何内容,只显示无法右键单击的白色区域.它在appletviewer或HTML文档中都不起作用,并且没有显示语法错误.我的代码出了什么问题?

import java.awt.*;
import java.applet.*;
import java.awt.geom.*;
import java.awt.image.BufferedImage;
import java.awt.event.*;


public class Shipmovementtest extends Applet implements Runnable,KeyListener{

    Graphics2D g2d;
    Ship ship1 = new Ship();
    BufferedImage backbuffer;
    AffineTransform identity = new AffineTransform();
    Shape ship1shape;
    Thread gameloop;
    public void start()
    {
        gameloop = new Thread(this);
        gameloop.start();
    }
    public void run()
    {
        Thread t = Thread.currentThread();
        while(gameloop==t)
        {
        try
        {
            Thread.sleep(20);
        }
        catch(InterruptedException e)
        {
            e.printStackTrace();
        }
        repaint();
        }
    }
    public void stop()
    {
        gameloop = null;
    }

    public void init()
    { …
Run Code Online (Sandbox Code Playgroud)

java applet doublebuffered awt appletviewer

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

Sturts 2会话失效,将请求会话设置为新会话

在我的Struts应用程序中,一旦用户登录,我需要使当前会话无效并创建新会话.我用会话使会话无效

getHttpServletRequest().getSession().invalidate();
Run Code Online (Sandbox Code Playgroud)

我创建了一个新会话

getHttpServletRequest().getSession(true);
Run Code Online (Sandbox Code Playgroud)

这里的问题是上面我尝试访问getSession()它后给出状态无效异常; HttpSession是无效的.

getSession()返回一个地图,在我的动作类中我实现了SessionAware哪个有setSession(Map session).

编辑:以下是例外

Error creating HttpSession due response is commited to client. You can use the CreateSessionInterceptor or create the HttpSession from your action before the result is rendered to the client: HttpSession is invalid
java.lang.IllegalStateException: HttpSession is invalid
Run Code Online (Sandbox Code Playgroud)

所以,我认为问题是Struts getSession()仍然引用我已经失效的会话.

如何让Struts getSession()引用我创建的新会话?

java struts2 httpsession

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

Java从String获取Substring值

我有字符串

 String path =    /mnt/sdcard/Album/album3_137213136.jpg
Run Code Online (Sandbox Code Playgroud)

我只想要字符串album3.我怎样才能得到那个子串.

我正在使用substring through index. 是否有其他方式,因为专辑号码正在改变,因为它会失败album9, album10.

java string split substring

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

如何在Android中开始使用Volley?

我看了谷歌io,看到了凌空.但我不知道如何开始它.我试图克隆https://android.googlesource.com/platform/frameworks/volley,但测试项目一直警告我"资源目录不存在".

请给我一些线索!

android

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

在action类中处理时获取参数+替换为空格

我使用加密文本"再见,朋友" BasicTextEncryptor.所以加密值如下所示,

3qe80L1ap+cR2zRU9csFwOffw5NtWTueLRYgSXyjctI=
Run Code Online (Sandbox Code Playgroud)

然后我将URL发送给用户,其中上述参数作为令牌.

然后用户复制以下URL并按Enter键,

http://localhost:8080/token=3qe80L1ap+cR2zRU9csFwOffw5NtWTueLRYgSXyjctI=
Run Code Online (Sandbox Code Playgroud)

但是当我通过action方法访问Struts 2应用程序中的参数时,它给出了如下的encrypt参数,

3qe80L1ap cR2zRU9csFwOffw5NtWTueLRYgSXyjctI=
Run Code Online (Sandbox Code Playgroud)

该+所取代" ".所以,当我解密时,它给了我EncryptionOperationNotPossibleException.

Struts是否解码+,以" "假设浏览器+是一个编码字符?在那种情况下,在我进行解密之前确定,我用空格替换+?

java encryption struts2

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

如果标记,我如何在struts2中使用请求参数

我有一个这样的链接:http://localhost:8080/ESA/login.jsp?login=failed 在上面的链接结束时设置一个名称login和值的参数failed.
我如何在带有struts的jsp页面中使用此参数if tag.我使用以下代码,但它不起作用.

<s:if test="%{#parameters.login='failed'}">
    <div class="error">
        <s:text name="user.login.failed"></s:text>
    </div>
</s:if>
Run Code Online (Sandbox Code Playgroud)

java jsp struts2 ognl http-request-parameters

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

为什么我可以在字符串中添加字符而不是字符添加字符?

所以我想在字符串中添加一个字符,并且在某些情况下想要将这些字符加倍,然后将其添加到字符串中(即首先添加到字符串中).我尝试了这个,如下所示.

char s = 'X'; 
String string = s + s;
Run Code Online (Sandbox Code Playgroud)

这引发了一个错误,但我已经在字符串中添加了一个字符,所以我尝试了:

String string = "" + s + s;
Run Code Online (Sandbox Code Playgroud)

哪个有效.为什么在求和中包含一个字符串会导致它起作用?是否添加了一个字符串属性,由于存在字符串,它们只能在字符转换为字符串时使用?

java string concat add char

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

为什么main应该出现在Java类中?

我们为什么要声明一个main方法?我知道这个main方法是课堂的起点.但为什么我们只应该宣布它public static void main(String args[])?

为什么我们不能宣布它public static void test(String args[])?main关键词是什么?JVM将如何知道它将成为起点?

java

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

java中的私有实例和getter可见性

并感谢每个人修复格式等,这里全新

我最近开始学习java,在一次练习中发生了一个问题,抱歉,如果我错过了发布规则:

从一个MyPoint到另一个Mypoint计算距离,我决定使用用于MyPoint吸气另一个因为x和y为另一个应该是私有的,并且不能在点操作(another.x another.y)中使用;

public class MyPoint {
    private int x;
    private int y;                   

    public int getX() {             
        return x;
    }

    public int getY() {            
        return y;
    } 

    public double distance(MyPoint another) { 
        int xDiff = this.x - another.getX();           //getter
        int yDiff = this.y - another.getY();          // getter

        return Math.sqrt(xDiff * xDiff + yDiff * yDiff);
    }
}

public class TestMyPoint {
    public static void main(String[] args) {
        MyPoint a = new MyPoint(3,0);
        MyPoint b = …
Run Code Online (Sandbox Code Playgroud)

java oop getter private

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

将方向从 ltr 更改为 rtl

你好吗 ?我买了这个模板(http://www.awerest.com/demo/syndicate/onepage/),它非常好,但我遇到了问题。我想将整个模板的方向更改为“rtl”。但它不起作用,事实上所有的变化都没有得到反映。

我添加了这个 CSS 但它也不起作用

html { direction:rtl;} body { direction: rtl     } section {    direction:rtl; } div {    direction:rtl;} ul     direction:rtl;}
Run Code Online (Sandbox Code Playgroud)

如果有人可以帮助我如何更改此模板方向,那就太好了,非常感谢。

css direction

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