如何从表单获取输入值到servlet

我的格式如下:

<form action="get_eD_XML" method="POST" enctype ="application/xml">
<input  value = '<?xml version="1.0" encoding="UTF-8"?><ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:epsos="urn:epsos-org:ep:medication" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><typeId extension="POCD_HD000040" root="2.16.840.1.113883.1.3"/><templateId root="1.3.6.1.4.1.12559.11.10.1.3.1.1.2"/><templateId root="1.3.6.1.4.1.19376.1.5.3.1.1.1"/><id extension="KoF9cw5Rjh7Waq/K" root="2.16.470.1.100.1.2.1000.990.1"/><code code="60593-1" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" codeSystemVersion="2.59" displayName="Medication dispensed.extended Document"><translation code="60593-1" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="eDispensation"/></code><title>Medication dispensed</title><effectiveTime value="20190624074224+0000"/><confidentialityCode code="N" codeSystem="2.16.840.1.113883.5.25" codeSystemName="Confidentiality" codeSystemVersion="913-20091020" displayName="normal"/><languagecode code="en-US"/><setId nullflavor="NI"/><recordTarget><patientRole><id extension="1" root="2.16.470.1.100.1.1.1000.990.1"/><addr><country>CY</country><streetaddressLine>21,Dimokritou,1000,Strovolos,Nicosia</streetaddressLine></addr><telecom use="H" value="tel:+99000000"/><telecom use="H" value="mailto:l.petr@testmail.com"/><patient><name><given>Leonidas</given><family>Petrou</family></name><administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1" codeSystemName="AdministrativeGender" codeSystemVersion="913-20091020" displayName="Male"/><birthTime value="19900101"/><languageCommunication><templateId root="1.3.6.1.4.1.19376.1.5.3.1.2.1"/><languagecode code="en-GB"/></languageCommunication></patient></patientRole></recordTarget><author typeCode="AUT"><functionCode code="2262" codeSystem="2.16.840.1.113883.2.9.6.2.7" codeSystemName="ISCO" codeSystemVersion="2008" displayName="Pharmacists"/><time value="20190624074224+0000"/><assignedAuthor classCode="ASSIGNED"><id extension="21229" root="2.16.470.1.100.1.2.1000.990.1"/><addr><streetaddressLine nullflavor="NI"/><city nullflavor="NI"/><state nullflavor="NI"/><postalCode nullflavor="NI"/><country>MT</country></addr><telecom use="WP" value="mailto:pharmacist@openncp.com"/><assignedPerson classCode="Psn" determinerCode="INSTANCE"><name><family nullflavor="NI"/><given>pharmacist</given></name></assignedPerson><representedOrganization><id extension="21229" root="2.16.470.1.100.1.2.1000.990.1"/><name> pharmacist</name><telecom use="WP" value="mailto:pharmacist@openncp.com"/><addr><streetaddressLine nullflavor="NI"/><city nullflavor="NI"/><state nullflavor="NI"/><postalCode nullflavor="NI"/><country>MT</country></addr></representedOrganization></assignedAuthor></author><custodian typeCode="CST"><assignedCustodian classCode="ASSIGNED"><representedCustodianOrganization classCode="ORG" determinerCode="INSTANCE"><id root="2.16.470.1.100.1.2.1000.990.1"/><name>Country Custodian Name</name><telecom nullflavor="NI"/><addr><country>MT</country></addr></representedCustodianOrganization></assignedCustodian></custodian><legalAuthenticator contextControlCode="OP" typeCode="LA"><time value="20120927112208"/><signatureCode code="S"/><assignedEntity classCode="ASSIGNED"><id root="2.16.470.1.100.1.2.1000.990.1"/><addr><streetaddressLine>4,Breydel Street</streetaddressLine><city>Brussels</city><postalCode>B-1000</postalCode><state nullflavor="UNK"/><country>BE</country></addr><telecom nullflavor="NI"/><assignedPerson><name><family>Firstname</family><given>Organisation</given></name></assignedPerson><representedOrganization classCode="ORG" determinerCode="INSTANCE"><id root="2.16.470.1.100.1.2.1000.990.1"/><name>Kansaneläkelaitos</name><telecom nullflavor="NI"/><addr use="PST"><streetaddressLine>N/A</streetaddressLine><city>City</city><postalCode>N/A</postalCode><state nullflavor="UNK"/><country>MT</country></addr></representedOrganization></assignedEntity></legalAuthenticator><inFulfillmentOf><order moodCode="RQO"><id extension="Prescriptions" root="2.16.620.1.101.10.3.29.54290"/></order></inFulfillmentOf><relatedDocument typeCode="XFRM"><parentDocument classCode="DOCCLIN"><id extension="Prescriptions" root="2.16.620.1.101.10.3.29.54290"/></parentDocument></relatedDocument><component><structuredBody><component><section><templateId root="2.16.840.1.113883.10.20.1.8"/><templateId root="1.3.6.1.4.1.12559.11.10.1.3.1.2.2"/><id extension="D-Prescriptions" root="2.16.470.1.100.1.2.1000.990.1"/><code code="60590-7" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" codeSystemVersion="2.59" displayName="Medication dispensed.brief Document"><translation code="60590-7" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Medication dispensed"/></code><title>Dispensation: D-Prescriptions</title><text><table width="100%"><thead><tr><th>active Ingredient (ATC)</th><th>Pharmaceutical Dose Form</th><th>Strength</th><th>Number of Units per intake</th><th>Frequency of Intake</th><th>Duration of treatment</th><th>Number of Prescribed Packages</th><th>Size of the package prescribed and package type</th><th>Route of Administration</th><th>Substitution</th><th>Onset Date of treatment</th><th>Instructions to patient</th><th>Advise to the dispenser</th></tr></thead><tbody><tr ID="medicine.1"><td>levothyroxine sodium (ATC: H03AA01)</td><td>Tablet</td><td>100 mg</td><td>1</td><td>1 before breakfast (from lat. ante cibus matutinus)</td><td>30 days</td><td>1</td><td>30 x 2 [iU]/mL,Blister</td><td>Oral use</td><td>none</td><td>2019-05-29</td><td>NA</td><td>NA</td></tr></tbody></table></text><entry typeCode="COMP"><supply classCode="SPLY" moodCode="EVN"><templateId root="2.16.840.1.113883.10.20.1.34"/><templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.3"/><templateId root="1.3.6.1.4.1.12559.11.10.1.3.1.3.3"/><id extension="medicine.1" root="2.16.470.1.100.1.2.1000.990.1"/><quantity unit="1" value="30.0"/><product><manufacturedProduct classCode="MANU"><templateId root="1.3.6.1.4.1.12559.11.10.1.3.1.3.1"/><manufacturedMaterial classCode="MMAT" determinerCode="KIND"><epsos:id extension="medicine.1" root="1.3.6.1.4.1.12559.11.10.1.3.1.3.3"/><code code="10219000" codeSystem="0.4.0.127.0.16.1.1.2.1" codeSystemName="EDQM" codeSystemVersion="2017-04-14" displayName="levothyroxine sodium"/><name>levothyroxine sodium</name><epsos:desc>100 mg</epsos:desc><epsos:formCode code="10219000" codeSystem="0.4.0.127.0.16.1.1.2.1" codeSystemName="EDQM" codeSystemVersion="2017-04-14" displayName="Tablet"/><epsos:asContent classCode="CONT"><epsos:containerPackagedMedicine classCode="CONT" determinerCode="INSTANCE"><epsos:name>levothyroxine sodium</epsos:name><epsos:formCode code="10219000" codeSystem="0.4.0.127.0.16.1.1.2.1" codeSystemName="EDQM" codeSystemVersion="2017-04-14" displayName="Tablet"/><epsos:capacityQuantity unit="1" value="2"/><epsos:capTypeCode nullflavor="NA"/></epsos:containerPackagedMedicine></epsos:asContent><epsos:asspecializedKind classCode="GEN"><epsos:generalizedMedicineclass classCode="MMAT"><epsos:code code="H03AA01" codeSystem="2.16.840.1.113883.6.73" codeSystemName="Anatomical Therapeutic Chemical" codeSystemVersion="2017-01" displayName="levothyroxine sodium"/><epsos:name>levothyroxine sodium,100 mg,30 x 2 [iU]/mL,Blister</epsos:name></epsos:generalizedMedicineclass></epsos:asspecializedKind><epsos:ingredient xmlns="urn:epsos-org:ep:medication" classCode="actI"><epsos:quantity><epsos:numerator unit="mg" value="100" xsi:type="epsos:PQ"/><epsos:denominator unit="[iU]/mL" value="1" xsi:type="epsos:PQ"/></epsos:quantity><epsos:ingredient classCode="MMAT" determinerCode="KIND"><epsos:code code="H03AA01" codeSystem="2.16.840.1.113883.6.73" codeSystemName="Anatomical Therapeutic Chemical" codeSystemVersion="2017-01" displayName="levothyroxine sodium"/><epsos:name>levothyroxine sodium</epsos:name></epsos:ingredient></epsos:ingredient></manufacturedMaterial></manufacturedProduct></product><performer typeCode="PRF"><time value="20190624074224+0000"/><assignedEntity><id extension="21229" root="2.16.470.1.100.1.2.1000.990.1"/><addr><streetaddressLine nullflavor="NI"/><city nullflavor="NI"/><state nullflavor="NI"/><postalCode nullflavor="NI"/><country>MT</country></addr><telecom use="WP" value="mailto:pharmacist@openncp.com"/><assignedPerson><name><family nullflavor="NI"/><given>pharmacist</given></name></assignedPerson><representedOrganization><id extension="21229" root="2.16.470.1.100.1.2.1000.990.1"/><name> pharmacist</name><telecom use="WP" value="mailto:pharmacist@openncp.com"/><addr><streetaddressLine nullflavor="NI"/><city nullflavor="NI"/><state nullflavor="NI"/><postalCode nullflavor="NI"/><country>MT</country></addr></representedOrganization></assignedEntity></performer><participant typeCode="PRF"><participantRole classCode="LIC"><id nullflavor="NI"/><scopingEntity classCode="ORG"><id nullflavor="NI"/></scopingEntity></participantRole></participant><entryRelationship typeCode="REFR"><substanceAdministration classCode="SBADM" moodCode="INT"><id extension="medicine.1" root="2.16.620.1.101.10.3.29.54290"/><text><reference value="#medicine.1"/></text><statusCode code="active"/><effectiveTime xsi:type="IVL_TS"><low value="20190529"/><high value="20190628"/></effectiveTime><effectiveTime institutionSpecified="true" operator="A" xsi:type="PIVL_TS"><period nullflavor="NA"/></effectiveTime><routeCode code="20053000" codeSystem="0.4.0.127.0.16.1.1.2.1" codeSystemName="EDQM" codeSystemVersion="2017-04-14" displayName="Oral use"/><doseQuantity nullflavor="UNK"/><consumable typeCode="CSM"><manufacturedProduct classCode="MANU"><templateId root="1.3.6.1.4.1.12559.11.10.1.3.1.3.1"/><manufacturedMaterial classCode="MMAT" determinerCode="KIND"><code code="10219000" codeSystem="0.4.0.127.0.16.1.1.2.1" codeSystemName="EDQM" codeSystemVersion="2017-04-14" displayName="Tablet"/><name>levothyroxine sodium</name><epsos:desc>100 mg</epsos:desc><epsos:formCode code="10219000" codeSystem="0.4.0.127.0.16.1.1.2.1" codeSystemName="EDQM" codeSystemVersion="2017-04-14" displayName="Tablet"/><epsos:asContent classCode="CONT"><epsos:containerPackagedMedicine classCode="CONT" determinerCode="INSTANCE"><epsos:name>Eurthyrox</epsos:name><epsos:formCode code="10219000" codeSystem="0.4.0.127.0.16.1.1.2.1" codeSystemName="EDQM" codeSystemVersion="2017-04-14" displayName="Tablet"/><epsos:capacityQuantity unit="1" value="2"/><epsos:capTypeCode nullflavor="NA"/></epsos:containerPackagedMedicine></epsos:asContent><epsos:asspecializedKind classCode="GEN"><epsos:generalizedMedicineclass classCode="MMAT"><epsos:code code="H03AA01" codeSystem="2.16.840.1.113883.6.73" codeSystemName="Anatomical Therapeutic Chemical" codeSystemVersion="2017-01" displayName="levothyroxine sodium"/><epsos:name>levothyroxine sodium,Blister</epsos:name></epsos:generalizedMedicineclass></epsos:asspecializedKind><epsos:ingredient xmlns="urn:epsos-org:ep:medication" classCode="actI"><epsos:quantity><epsos:numerator unit="mg" value="100" xsi:type="epsos:PQ"/><epsos:denominator unit="[iU]/mL" value="1" xsi:type="epsos:PQ"/></epsos:quantity><epsos:ingredient classCode="MMAT" determinerCode="KIND"><epsos:code code="H03AA01" codeSystem="2.16.840.1.113883.6.73" codeSystemName="Anatomical Therapeutic Chemical" codeSystemVersion="2017-01" displayName="levothyroxine sodium"/><epsos:name>levothyroxine sodium</epsos:name></epsos:ingredient></epsos:ingredient></manufacturedMaterial></manufacturedProduct></consumable><entryRelationship typeCode="COMP"><sequenceNumber value="1"/><supply classCode="SPLY" moodCode="RQO"><independentInd value="false"/><quantity unit="{packages}" value="30.0"/></supply></entryRelationship><entryRelationship inversionInd="true" typeCode="SUBJ"><observation classCode="OBS" moodCode="EVN"><code code="SUBST" codeSystem="2.16.840.1.113883.5.6" codeSystemName="actClass" displayName="Substitution"/><value code="N" codeSystem="2.16.840.1.113883.5.1070" codeSystemName="SubstanceAdminSubstitution" codeSystemVersion="913-20091020" displayName="none" xsi:type="CD"/></observation></entryRelationship></substanceAdministration></entryRelationship></supply></entry></section></component></structuredBody></component></ClinicalDocument>'/>
<input type="submit" value="Test" />
</form>

我需要获取输入值。

我正在使用以下servlet代码获取输入值,但是String eD为空。有什么帮助吗?

@WebServlet("/get_eD_XML")
public class get_eD_XML extends CEFCYServlet {
private static final long serialVersionUID = 1L;
//private PatientSummaryConf globalVal;
public get_eD_XML() 
{
  super();
}
protected void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException 
{
  doPost(request,response);
}
protected void doPost(HttpServletRequest request,IOException 
{
 String eD = IOUtils.toString(request.getReader());
 System.out.println(eD);
}
}
lchfeiniao 回答:如何从表单获取输入值到servlet

按如下所示更改输入:

<input type="hidden" name="param1" value="your value" /> 

在servlet中,您可以获取它:

     protected void doPost(HttpServletRequest request,HttpServletResponse response)
            throws ServletException,IOException {
                    String eD = request.getParameter("param1");

                    System.out.println(eD);

     }

更新:

W3C规范要求每个表单输入元素都必须指定一个name属性。否则,该元素将不会被处理。

Source

本文链接:https://www.f2er.com/3117443.html

大家都在问