Learn Java Web with Argentina Four development: For information transmission and information transmission

Source: Internet
Author: User

Send SMS and general authentication and user registration system Message prompt function module, but the implementation code is too complex. After using Jspgen, the deep sending of messages, SMS packages makes complex simplicity very active.

In the SMS module: support two modes, they are sent to the third party, the local platform to send, the way (adopt the local platform to send without configuration, according to the text message send interface file rewrite the corresponding implementation class can).

first, the basic configuration

Jspgen-config.xml
In the Framework foundation configuration file, locate the mail node and the SMS node, as in the following configuration:

    <!--Mail Service-<mail status= "true" > <smtp> <!--send type (SMTP MX)--           <type>SMTP</type> <server>smtp.163.com</server> <port>25</port> <email>[email protected]</email> <name>jspgen official website </name> <userna Me>jspgen</username> <password>jspgen</password> <!--content format (text HTML URL)--&G           T <format>html</format> <!--content Signing--<sign>jspgen-making Java (WEB) software development more agile! Www.       Jspgen.com</sign> </smtp> </mail> <!--SMS Service (HTTP)--<sms status= "true" > <!--Submit address and method (GET POST)-<url> send address </url> <method>GET</method> <cha rset>utf-8</charset> <username> <key>name</key> &LT;VALUE&GT;JSPGEN&L   T;/value>    </username> <password> <key>password</key> <value>jspgen</v Alue> </password> <!--support Batch send-<mobile batch= "false" > <key>mob ile</key> <gap>;</gap> </mobile> <content> <key>msg&lt ;/key> </content> <time> <key>dtime</key> <!--time format, empty is long       Time Stamp-<format>yyyy-mm-dd hh:mm:ss</format> </time> <!--return Data--  <return> <!--return format (text XML JSON)--<format>text</format> <!-- returns keyword. When formatted as Xml/json utility--<key>status</key> <!--return Success ID--<value>0< /value> </return> <!--content Signing--<sign> "Jspgen" </sign> </sms>

Second, the code implementation

1, Sendaction.java

Package Demo.action;import grapes. Dates;import grapes. Files;import grapes. Grapes;import grapes.tools.browser;import java.io.file;import Java.net.malformedurlexception;import Java.net.URL; Import Java.util.arraylist;import java.util.list;import java.util.map;import jspgen.action.action;/** * Action class: Send message and send SMS * * @author Jspgen * @copyright (c) jspgen.com * @created March 2013 * @email [email protected] * @a ddress www.jspgen.com */public class SendAction extends Action {/** * default method */@Override P       Ublic String Execute () {return ' mail ';              /** * Send mail Submission */public String Mail () {Boolean isflag = false;              Long time = Dates.gettimemillis (); String to = GetParameter ("to"); Receive form values (form name: to) Isflag = SendMail (To, GetParameter ("subject"), GetParameter ("content"), time);                     Send in if (!isflag) {addactionerror ("Send failed!");return ERROR;              } addactionmessage ("Sent successfully!");       return SUCCESS;              /** * Send text message submission */public String SMS () {Boolean isflag = false;              Long time = Dates.gettimemillis (); String to = GetParameter ("to"); Receive form values (form name: to) Isflag = Sendsms (To, GetParameter ("content"), time);                     Send in if (!isflag) {addactionerror ("Send failed!");              return ERROR;              } addactionmessage ("Sent successfully!");       return SUCCESS; }}

2. Mail.html Portal page Template

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

Third, Test

Direct input in the browser: Http://localhost:8080/jspgensdf/send.gen

Note:163 just register the account can not be sent, as if the need for two months after the ability to use, can build a mail service environment, to test.

Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.

Learn Java Web with Argentina Four development: For information transmission and information transmission

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.