首页 文章 精选 留言 我的

精选列表

搜索[ssh客户端],共10010篇文章
优秀的个人博客,低调大师

SSH框架整合遇到的错误——org.springframework.beans.NotWritablePropertyException:

提示错误信息: Unable to instantiate Action, userAction, defined for 'user_registPage' in namespace '/'Error creating bean with name 'userAction' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userService' of bean class [com.itcast.shop.user.action.UserAction]: Bean property 'userService' is not writable or has an invalid setter method. Did you mean 'userservive'? - action - file:/D:/Program%20Files%20(x86)/apache-tomcat-9.0.1/webapps/shop/WEB-INF/classes/struts.xml:36:56 com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:320) com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:401) com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:201) org.apache.struts2.factory.StrutsActionProxy.prepare(StrutsActionProxy.java:57) org.apache.struts2.factory.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:32) com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:60) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:564) org.apache.struts2.dispatcher.ExecuteOperations.executeAction(ExecuteOperations.java:79) org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:141) 出现此问题的原因是在ApplicationContext.xml中配置有问题,里面的bean的属性名称用 与 注入的类名称不一致 applicationContext.xml <!-- 用户模块的Action --> <bean id="userAction" class="com.itcast.shop.user.action.UserAction" scope="prototype"> <property name="userService" ref="userService"/> </bean> userAction private UserDaouserdao; private UserService userService; public void setUserservive(UserService userService) { this.userService = userService; } 红色部分名称要一致。

优秀的个人博客,低调大师

SSH框架整合遇到的错误——Hibernate查询语句出现错误

在调试前台注册界面,填写注册信息,用户名Ajax异步验证时报错,报错文件在Dao文件的查询语句中。 报错信息: java.lang.IllegalArgumentException: org.hibernate.QueryException: Legacy-style query parameters (`?`) are no longer supported; use JPA-style ordinal parameters (e.g., `?1`) instead : from com.itcast.shop.user.vo.User where username = ? [from com.itcast.shop.user.vo.User where username = ?] at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:133) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:164) at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:713) at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:103) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 错误原因:find方法过时,导致HQL语句格式必须改变才能使用。 将HQL语句中的"?"改为JPA-style: String hql="from User where username = ?0"; 这样就可以正确查询到信息了。

优秀的个人博客,低调大师

简单的邮件客户端

运行界面如下: 源代码如下:(本程序使用的是Merak mail server) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 package com.zzk; /** * @author 任文超 * @version 1.0 * */ import java.awt.Color; import java.awt.EventQueue; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Date; import java.util.Properties; import javax.mail.Message; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; public class SendMailFrame extends JFrame { private JTextArea ta_text; private JTextField tf_title; private JTextField tf_send; private JTextField tf_receive; private Session session; // 定义Session对象 private String sendHost = "localhost" ; // 定义发送邮件的主机 private String sendProtocol= "smtp" ; // 定义使用的发送协议 public static void main(String args[]) { EventQueue.invokeLater( new Runnable() { public void run() { try { SendMailFrame frame = new SendMailFrame(); frame.init(); frame.setVisible( true ); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame */ public SendMailFrame() { super (); setTitle( "发送邮件窗体" ); getContentPane().setLayout( null ); setBounds( 100 , 100 , 439 , 299 ); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JLabel label = new JLabel(); label.setForeground( new Color( 0 , 0 , 255 )); label.setFont( new Font( "" , Font.BOLD, 22 )); label.setText( "发送电子邮件" ); label.setBounds( 144 , 10 , 185 , 24 ); getContentPane().add(label); final JLabel label_1 = new JLabel(); label_1.setText( "收件人地址:" ); label_1.setBounds( 22 , 42 , 85 , 18 ); getContentPane().add(label_1); tf_receive = new JTextField(); tf_receive.setBounds( 113 , 40 , 287 , 22 ); getContentPane().add(tf_receive); final JLabel label_2 = new JLabel(); label_2.setText( "发件人地址:" ); label_2.setBounds( 22 , 68 , 78 , 18 ); getContentPane().add(label_2); tf_send = new JTextField(); tf_send.setBounds( 113 , 66 , 287 , 22 ); getContentPane().add(tf_send); final JLabel label_3 = new JLabel(); label_3.setText( "主 题:" ); label_3.setBounds( 32 , 92 , 66 , 18 ); getContentPane().add(label_3); tf_title = new JTextField(); tf_title.setBounds( 113 , 94 , 287 , 22 ); getContentPane().add(tf_title); final JLabel label_4 = new JLabel(); label_4.setText( "正 文:" ); label_4.setBounds( 34 , 128 , 66 , 18 ); getContentPane().add(label_4); final JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds( 113 , 128 , 287 , 91 ); getContentPane().add(scrollPane); ta_text = new JTextArea(); scrollPane.setViewportView(ta_text); final JButton btn_send = new JButton(); btn_send.addActionListener( new ActionListener() { public void actionPerformed( final ActionEvent e) { String fromAddr = tf_send.getText().trim(); String toAddr = tf_receive.getText().trim(); // 真实存在的目标邮件地址 String title = tf_title.getText().trim(); String text = ta_text.getText().trim(); try { sendMessage(fromAddr, toAddr, title, text); } catch (Exception e1) { e1.printStackTrace(); } } }); btn_send.setText( "发 送" ); btn_send.setBounds( 144 , 225 , 78 , 28 ); getContentPane().add(btn_send); final JButton btn_exit = new JButton(); btn_exit.addActionListener( new ActionListener() { public void actionPerformed( final ActionEvent e) { System.exit( 0 ); } }); btn_exit.setText( "退 出" ); btn_exit.setBounds( 279 , 225 , 78 , 28 ); getContentPane().add(btn_exit); } public void init() throws Exception { Properties props = new Properties(); // 创建属性对象 props.put( "mail.transport.protocol" , sendProtocol); // 指定邮件传输协议 props.put( "mail.smtp.class" , "com.sun.mail.smtp.SMTPTransport" ); //指定传输协议使用的类 props.put( "mail.smtp.host" , sendHost); // 定义发送邮件的主机 session = Session.getDefaultInstance(props); // 创建Session对象 } /** * @param fromAddr 发送者 * @param toAddr 接收者 * @param title 主题 * @param text 内容 * @throws Exception 异常 */ public void sendMessage(String fromAddr,String toAddr,String title,String text) throws Exception { Message msg = new MimeMessage(session); // 创建Message对象 InternetAddress[] toAddrs = InternetAddress.parse(toAddr, false ); // 创建接收方的InternetAddress对象 msg.setRecipients(Message.RecipientType.TO, toAddrs); // 指定接收方 msg.setSentDate( new Date()); // 指定接发送日期 msg.setSubject(title); // 设置主题 msg.setFrom( new InternetAddress(fromAddr)); // 指定发送者 msg.setText(text); // 指定发送内容 Transport.send(msg); // 发送邮件 JOptionPane.showMessageDialog( null , "邮件发送成功。" ); } } ============================================================================== 本文转自被遗忘的博客园博客,原文链接:http://www.cnblogs.com/rollenholt/archive/2011/10/19/2217431.html,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

用户登录
用户注册