我正在尝试完成一项任务。我需要打印@Component
public class DepartmentEditor extends PropertyEditorSupport{
@Autowired
DepartmentService depService;
@Override
public String getAsText() {
return super.getAsText();
}
@Override
public void setAsText(String value) throws IllegalArgumentException {
if(value.isEmpty()){
try {
Department dep = depService.findById(Integer.parseInt(value));
if (null!=dep) {
setValue(dep);
} else {
throw new IllegalArgumentException("Binding error. Cannot find userAccount with id ["+value+"]");
}
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Binding error. Invalid id: " + value);
}
} else {
setValue(null);
}
}
}
(下面指定)。但它不打印我不知道什么似乎是问题。我提前感谢你的帮助......我不想在html代码中做这个echo $ message的事情。有一点你应该知道值是在echo $message
之前打印的。 php变量在echo $message
之前有值,但是当我回显$message
时,这些相同的变量什么都不打印..它只打印
客户名称:
客户电邮:
客户手机:
客户城市:
客户结算地址:
$message
HTML文件:
<?php
if(isset($_POST['sub'])){
$name=$_POST['name'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$city=$_POST['city'];
$bill_add=$_POST['message'];
echo $message="
<html><head> </head>
<body>
Customer Name: <?php echo $name; ?>
<br>
Customer Email: <?php echo $email; ?>
<br>
Customer Mobile: <?php echo $mobile; ?>
<br>
Customer City: <?php echo $city; ?>
<br>
Customer Billing Address: <?php echo .$bill_add; ?>
</body></html>";}
?>
答案 0 :(得分:4)
将您的$message
更改为:
echo $message="
<html><head> </head>
<body>
Customer Name: $name
<br>
Customer Email: $email
<br>
Customer Mobile: $mobile
<br>
Customer City: $city
<br>
Customer Billing Address: $bill_add
</body></html>";}
?>
问题在于您将<?php echo
用于<?php echo
答案 1 :(得分:1)
尝试:
<?php
if(isset($_POST['sub'])){
$name=$_POST['name'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$city=$_POST['city'];
$bill_add=$_POST['message'];
echo "
<html><head> </head>
<body>
Customer Name: ".$name."
<br>
Customer Email: ".$email."
<br>
Customer Mobile: ".$mobile."
<br>
Customer City: ".$city."
<br>
Customer Billing Address: ".$bill_add."
</body></html>";}
?>
答案 2 :(得分:1)
你无法使用
这样可以更好地使用它,在php中使用连接解决了你的问题。
<?php
echo $message="
<html><head> </head>
<body>
Customer Name: ".$name."
<br>
Customer Email: ".$email."
<br>
Customer Mobile: ".$mobile."
<br>
Customer City: ".$city."
<br>
Customer Billing Address: ".$bill_add."
</body></html>";
?>
答案 3 :(得分:1)
<?php echo $message="<html><head> </head><body>Customer Name: " . $name . " <br>Customer Email: " . $email . " <br>Customer Mobile: " . $mobile . " <br>Customer City: " . $city . "<br>Customer Billing Address: " . $bill_add . " </body></html>";?>
//我们在这里使用连接(。)所以我们不需要编写和删除空格。