小编Mic*_*ael的帖子

我的web.xml中不允许使用element listener-class

我的web.xml出了问题.我得到以下错误:"元素监听器类不允许在这里".谁知道哪里可能有问题?thx的答案.

我的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">

    <display-name>zkspringcoresec</display-name>


    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/applicationContext-security.xml
        </param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>


    <servlet>
        <servlet-name>DispatcherServlet</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                /WEB-INF/default-servlet.xml
            </param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>DispatcherServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <!--Spring security-->
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!--Spring security-->
    <!--ZK-->
    <listener>
        <description>Used to cleanup when a session is destroyed</description>
        <listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
    </listener>


    <servlet>
        <servlet-name>zkLoader</servlet-name>
        <servlet-class>
            org.zkoss.zk.ui.http.DHtmlLayoutServlet
        </servlet-class>
        <init-param>
            <param-name>update-uri</param-name>
            <param-value>/zkau</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>zkLoader</servlet-name>
        <url-pattern>*.zul</url-pattern>
    </servlet-mapping>
    <servlet-mapping> …
Run Code Online (Sandbox Code Playgroud)

spring-mvc zk

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

Spring,如何使用websockets向连接的客户端广播消息?

我想在我的应用程序中使用websockets.我已经按照本教程:http: //spring.io/guides/gs/messaging-stomp-websocket/

它完美地运作.

当其中一个连接的客户端按下按钮时,将调用此方法:

@MessageMapping("/hello")
@SendTo("/topic/greetings")
public Greeting greeting() throws Exception {
    System.out.println("Sending message...");
    Thread.sleep(1000); // simulated delay
    return new Greeting("hello!");        
}
Run Code Online (Sandbox Code Playgroud)

并且消息被广播给所有连接的客户端.

现在我想修改我的服务器应用程序,它将定期(每小时)向所有连接的客户端广播消息,而无需客户端的交互.

像这样的东西(但这显然不起作用):

@Scheduled(fixedRate = 3600000)
public void sendMessage(){
   try {
   @SendTo("/topic/greetings")     
   greeting();
    } catch (Exception e) {
        e.printStackTrace(); 
    }
}
Run Code Online (Sandbox Code Playgroud)

感谢建议.

java spring stomp

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

如何将jscrollpane添加到jframe?

我有以下源代码...有人可以给我一个如何将jscrollpane添加到jframe的建议吗?我尝试了几次将它添加到jframe但没有任何进展.它甚至没有显示出来.

public class Form3 {
        JFrame jframe = new JFrame("Etiket print.");
        JPanel panel1 = new JPanel();
        JPanel panel2 = new JPanel();
        JPanel panel3 = new JPanel();
        JPanel panel4 = new JPanel();
        JScrollPane scrollFrame = new JScrollPane(panel2);
        Color myBlue1Color = new Color(168, 175, 247);
        Color myBlue2Color = new Color(139, 146, 255);



           public Form3(){
                jframe.setMinimumSize(new Dimension(1280, 1000));
                panel2.setLayout(new BoxLayout(panel2, BoxLayout.Y_AXIS));
                panel2.setAutoscrolls(true);
                jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

                //---------------------------------Header
                panel1 = createSquareJPanel(Color.YELLOW, 600,200);
                panel3 = createSquareJPanel(Color.GREEN, 400,200);
                panel4 = createSquareJPanel(Color.white, 280,200);
                JPanel container = new JPanel();
                JPanel container1 …
Run Code Online (Sandbox Code Playgroud)

java layout swing jscrollpane border-layout

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

如何在JFrame中运行2个线程

嗨我有以下问题...我有这样的主jframe开始:

public static void main (String args[]){
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            Form3 myF=new Form3();                    
        }
    });
};
Run Code Online (Sandbox Code Playgroud)

在jframe我有Jpanels.在jpanel上我想开始第二个帖子.我试过这样的:

try {
    while (DBAccess.haveResult("ASS"+harnessId)==null&&cancelCycle == 0) {

        thread1.sleep(3*1000);
        System.out.println("+++++++++");
        System.out.println(DBAccess.haveResult("ASS"+harnessId));
        res = DBAccess.haveResult("ASS"+harnessId);

    }

} catch (InterruptedException e) {
    e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

但是我无法阻止那个线程,甚至无法取消它,因为主窗口停止反应

澄清我的问题:我在JPanel上有"测试"按钮,它正在启动测试过程.测试过程包括循环,每3秒重复一次,此循环检查数据库状态.问题是我无法停止此循环,直到状态出现在db(条件)中,因为我点击"test"后窗口很忙.即使实现runnable并将测试方法放入"run()"也无效.

testbutton源代码:

if (e.getActionCommand().equals("Test")){
            run();}
Run Code Online (Sandbox Code Playgroud)

运行方法:

@Override
    public final void run() {
        test();
    }
Run Code Online (Sandbox Code Playgroud)

测试方法:

Map result_row =  DBAccess.addRow("ASS"+harnessId,htOperList.get(seqNumber-1).getNametestprogram(),"",null);
                if(result_row.containsKey("ADDROW")){System.out.println("Record inserted" );}
                Database db = null;
                Map res = null;                
                try {
                    while (DBAccess.haveResult("ASS"+harnessId)==null&&cancelCycle == 0) …
Run Code Online (Sandbox Code Playgroud)

java concurrency swing event-dispatch-thread thread-sleep

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

使用@ManyToMany批注时获取重复记录

我有3个表:1.moduls具有属性id,2.variant具有属性id和3.moduls_variant具有属性moduls_id,variant_id。

我将这些表映射为两个类:

模数

@Entity
@Table (name = "moduls")
public class Moduls
    {

    @Id
    @GeneratedValue (strategy = GenerationType.IDENTITY)
    @Column (name = "id")...
   }
Run Code Online (Sandbox Code Playgroud)

变体

@Table(name = "variant")
@Entity
public class Variant{
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column (name = "id", unique = true)
    private Integer id;
    @ManyToMany(fetch = FetchType.EAGER,cascade =    CascadeType.ALL)
    @JoinTable(name = "moduls_variant",
    joinColumns = @JoinColumn(name = "variant_id") ,
    inverseJoinColumns =  @JoinColumn(name = "moduls_id") )
    private Set<Moduls> modulsSet = new HashSet<Moduls>();...
    }
Run Code Online (Sandbox Code Playgroud)

还有我的问题。可以说,我进入表时会调制ID为1,2和3的项目。在ID为1的表格变体项目中,最后在表格moduls_variant 3行中:

1 | 1

1 | 2

1 …

hibernate jpa

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